825bee3a45b2e7d96f0b8356a88028fefd1c6b5f
[integration.git] / deployment / noheat / infra-openstack / ansible / create.yml
1 ---
2 - name: Prepare infrastructure and create operation instances
3   hosts: localhost
4   connection: local
5   gather_facts: False
6   roles:
7     - create_network
8     - create_securitygroup
9     - create_keypair
10     - role: create_hosts
11       hosts: "{{ operation.hosts }}"
12       operator_key: "dummy"
13 - name: Create cluster operator access keypair
14   hosts: "operator0"
15   gather_facts: False
16   tasks:
17     - name: Wait for system to become reachable
18       wait_for_connection:
19     - name: Generate an OpenSSH keypair with the default values (4096 bits, rsa)
20       community.crypto.openssh_keypair:
21         path: "~/.ssh/{{ keypair.name }}"
22       register: key
23     - name: Add operator0 public key to it's authorized keys
24       authorized_key:
25         key: "{{ key['public_key'] }}"
26         state: present
27         user: "{{ ansible_user }}"
28 - name: Create cluster instances
29   hosts: localhost
30   connection: local
31   gather_facts: False
32   roles:
33     - role: create_hosts
34       hosts: "{{ cluster.hosts }}"
35       operator_key: "{{ hostvars['operator0']['key']['public_key'] }}"
36 - name: Create cluster operator access information
37   hosts: "operator0"
38   roles:
39     - role: geerlingguy.ansible
40       become: yes
41   tasks:
42     - name: Add cluster hostnames to /etc/hosts file
43       lineinfile:
44         path: /etc/hosts
45         line: "{{ item.value + ' ' + item.key }}"
46       become: yes
47       loop: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
48     - name: Create inventory for in-cluster deployment stage
49       template:
50         src: templates/inventory.ini.j2
51         dest: "{{ operation.inventory }}"
52       vars:
53         hosts: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
54     - name: Push in-cluster deployment stage description to the next Ansible control host
55       ansible.posix.synchronize:
56         src: ../../cluster-rke
57         dest: ~/deploy
58     - name: Install python dependencies
59       become: yes
60       package:
61         name:
62           - python3-pip
63           - python3-setuptools
64         state: present
65     - name: Install community.kubernetes.k8s Ansible collection dependencies
66       pip:
67         name:
68           - openshift
69           - pyyaml
70           - kubernetes
71         executable: pip3
72       become: yes
73     - name: Add Ansible collection dependencies
74       command: "ansible-galaxy collection install ansible.posix"
75     - name: Add community.kubernetes Ansible collection
76       command: "ansible-galaxy collection install community.kubernetes"