-
Notifications
You must be signed in to change notification settings - Fork 3
/
user_equivalency.yml
55 lines (44 loc) · 1.79 KB
/
user_equivalency.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
---
# ==============================================================================
# Manage User Equivalency between all nodes of a cluster
# (1) Generate SSH keys on first node only
# (2) Copy SSH private and public keys back to Ansible server
# (3) Add public key to authorized keys
# (4) Add nodes of cluster to known hosts file
# ==============================================================================
# --------------------- Generate SSH keys on first node only
- name: "Generate and copy SSH keys for first node only"
user:
name: oracle
generate_ssh_key: yes
when: first_node
# --------------------- Copy SSH private and public keys back to Ansible server
- block:
- name: "Retrieve SSH Public Key from first node only"
fetch:
src: /home/oracle/.ssh/id_rsa.pub
dest: /etc/ansible/keys/redfern/
flat: yes
- name: "Retrieve SSH Private Key from first node only"
fetch:
src: /home/oracle/.ssh/id_rsa
dest: /etc/ansible/keys/redfern/
flat: yes
when: first_node
# --------------------- Add public key to authorized keys
- name: "Add public key to authorized keys"
authorized_key:
user: oracle
state: present
key: "{{ lookup('file', '/etc/ansible/keys/redfern/id_rsa.pub') }}"
# --------------------- Add nodes of cluster to known hosts file
- include_tasks: add_host_to_known_hosts.yml
with_items:
- redfern1
- redfern1.yaocm.id.au
loop_control:
loop_var: new_host_name
become: yes
become_user: oracle
tags: add_host_to_known_hosts
...