Prepare operation machine for in-cluster deployment stage
[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: Create cluster instances
24   hosts: localhost
25   connection: local
26   gather_facts: False
27   roles:
28     - role: create_hosts
29       hosts: "{{ cluster.hosts }}"
30       operator_key: "{{ hostvars['operator0']['key']['public_key'] }}"
31 - name: Create cluster operator access information
32   hosts: "operator0"
33   roles:
34     - role: geerlingguy.ansible
35       become: yes
36   tasks:
37     - name: Add cluster hostnames to /etc/hosts file
38       lineinfile:
39         path: /etc/hosts
40         line: "{{ item.value + ' ' + item.key }}"
41       become: yes
42       loop: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"
43     - name: Create inventory for in-cluster deployment stage
44       template:
45         src: templates/inventory.ini.j2
46         dest: "{{ operation.inventory }}"
47       vars:
48         hosts: "{{ lookup('dict', hostvars['localhost']['hosts_dict']) }}"