File tree Expand file tree Collapse file tree 6 files changed +36
-6
lines changed
Expand file tree Collapse file tree 6 files changed +36
-6
lines changed Original file line number Diff line number Diff line change 11- hosts : ceph-cluster
2+ gather_facts : no
3+ tasks :
4+ - name : list local facts and register it in a variable
5+ local_action : shell basename `ls -1 ./files/facts/*.fact`
6+ register : list_local_facts
7+ - name : ensure /etc/ansible/facts.d/ exists
8+ file : path=/etc/ansible/facts.d state=directory owner=root group=root mode=0755
9+ - name : copy all facts on nodes
10+ copy : src=./files/facts/{{item}} dest=/etc/ansible/facts.d/{{item}} mode=0755
11+ with_items : list_local_facts.stdout_lines
12+ - name : gathering facts
13+ setup :
14+ # - name: debug toto
15+ # debug: var=hostvars[item]['ansible_local']['ssh_key_pub'].get("ssh_key_pub")
16+ # with_items: groups['ceph-cluster']
217 roles :
3- - common
4- - ceph
18+ - common
19+ - ceph
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ FILE=/root/.ssh/id_rsa
4+
5+ SSH_PUB_KEY=` cat ${FILE} .pub`
6+
7+ cat << EOF
8+ {
9+ "ssh_key_pub" : "$SSH_PUB_KEY "
10+ }
11+ EOF
Original file line number Diff line number Diff line change 11# Here will be included the differents tasks for a ceph node
2+ - name : gathering facts
3+ setup :
4+ - include : ssh_key.yml
Original file line number Diff line number Diff line change 1+ - name : put all nodes ssh pub key
2+ lineinfile : dest=/root/.ssh/authorized_keys create=yes owner=root group=root mode=0644 state=present line="{{hostvars[item]['ansible_local']['ssh_key_pub'].get('ssh_key_pub')}}"
3+ with_items : groups['ceph-cluster']
Original file line number Diff line number Diff line change 11---
22# Common task for all nodes
33
4+ - name : gathering facts
5+ setup :
46- include : ssh_keys.yml
57- include : repo.yml
68- include : packages.yml
Original file line number Diff line number Diff line change 22- name : Add ssh keys
33 lineinfile : dest=/root/.ssh/authorized_keys create=yes owner=root group=root mode=0644 state=present line="{{item}}"
44 with_items : keys
5-
65- name : check if ssh keys are present for root
76 stat : path=/root/.ssh/id_rsa.pub
87 register : p
9-
108# TODO: if /root/.ssh/id_rsa exists but is a directory, we will have a problem..
119# TODO: maybe we could put the path in a variable
1210- name : create ssh keys if necessary
1311 command : " ssh-keygen -t rsa -b 2048 -q -f /root/.ssh/id_rsa -N ''"
1412 when : p.stat.exists == false
15-
16- # - debug: var=ssh_pub_key
You can’t perform that action at this time.
0 commit comments