blob: 847efa25fc0ca052f2fff0a991579bd9185503e4 (
plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
---
- name: Prepare infrastructure and create operation instances
hosts: localhost
connection: local
gather_facts: False
roles:
- create_network
- create_securitygroup
- create_keypair
- role: create_hosts
hosts: "{{ operation.hosts }}"
operator_key: "dummy"
- name: Create cluster operator access keypair
hosts: "operator0"
gather_facts: False
tasks:
- name: Wait for system to become reachable
wait_for_connection:
- name: Generate an OpenSSH keypair with the default values (4096 bits, rsa)
community.crypto.openssh_keypair:
path: "~/.ssh/{{ keypair.name }}"
register: key
- name: Add operator0 public key to it's authorized keys
authorized_key:
key: "{{ key['public_key'] }}"
state: present
user: "{{ ansible_user }}"
- name: Create cluster instances
hosts: localhost
connection: local
gather_facts: False
roles:
- role: create_hosts
hosts: "{{ cluster.hosts }}"
operator_key: "{{ hostvars['operator0']['key']['public_key'] }}"
- name: Create cluster operator access information
hosts: "operator0"
roles:
- role: geerlingguy.ansible
become: yes
tasks:
- name: Add cluster hostnames to /etc/hosts file
lineinfile:
path: /etc/hosts
line: "{{ item.value + ' ' + item.key }}"
become: yes
loop: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
- name: Create inventory for in-cluster deployment stage
template:
src: templates/inventory.ini.j2
dest: "{{ operation.inventory }}"
vars:
hosts: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
- name: Push in-cluster deployment stage description to the next Ansible control host
ansible.posix.synchronize:
src: ../../cluster-rke
dest: ~/deploy
- name: Install python dependencies
become: yes
package:
name:
- python3-pip
- python3-setuptools
state: present
- name: Install community.kubernetes.k8s Ansible collection dependencies
pip:
name:
- openshift
- pyyaml
- kubernetes
become: yes
- name: Add Ansible collection dependencies
command: "ansible-galaxy collection install ansible.posix"
- name: Add community.kubernetes Ansible collection
command: "ansible-galaxy collection install community.kubernetes"
|