--- - 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" tasks: - name: Get operator Openstack info openstack.cloud.server_info: server: "operator0" register: operator_info - name: Create directory for artifacts ansible.builtin.file: name: "artifacts" state: directory mode: '0755' - name: Save operator access information ansible.builtin.copy: content: "{{ operator_info['openstack_servers'][0]['public_v4'] }},{{ image['user'] }},~/.ssh/{{ keypair['key']['name'] }}" dest: "artifacts/operator.csv" mode: "0644" - 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 ansible.posix.authorized_key: key: "{{ key['public_key'] }}" state: present user: "{{ ansible_user }}" - name: Create OpenStack instances hosts: localhost connection: local gather_facts: False roles: - role: create_hosts hosts: "{{ openstack.hosts }}" operator_key: "{{ hostvars['operator0']['key']['public_key'] }}" - 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" vars_files: - ../../common-vars.yml 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 copy: src: ../../cluster-rke dest: ~/deploy - name: Push Devstack deployment stage description to the next Ansible control host copy: src: ../../devstack dest: ~/ - name: Push common variables to the next Ansible control host copy: src: ../../common-vars.yml dest: ~/ - name: Push Devstack vars to the next Ansible control host (for Devstack stage) template: src: "templates/openstack.yml.j2" dest: ~/devstack/ansible/group_vars/all/openstack.yml mode: '0644' - name: Push Devstack vars to the next Ansible control host (for cluster-rke stage) template: src: "templates/openstack.yml.j2" dest: ~/deploy/cluster-rke/ansible/group_vars/all/openstack.yml mode: '0644' - name: Create Devstack config directory file: path: ~/.config/openstack/ state: directory mode: '0755' - name: Generate Devstack clouds.yml file template: src: "templates/clouds.yaml.j2" dest: ~/.config/openstack/clouds.yml mode: '0644' - block: - name: Install python dependencies become: yes apt: name: - python3-pip - python3-setuptools - default-jdk-headless state: present update_cache: true - name: Install community.kubernetes.k8s Ansible collection dependencies pip: name: - ansible-core==2.13.5 - openshift==0.13.1 - pyyaml==6.0 # Major version of Python k8s libraty matches minor version of k8s. - kubernetes~={{ k8s_version | regex_search("[^^.][0-9]+[^$]") ~ "0" }} executable: pip3 become: yes - name: Copy ansible-galaxy requirements file copy: src: operator-requirements.yml dest: ~/requirements.yml mode: '0444' - name: Install ansible-galaxy collections community.general.ansible_galaxy_install: requirements_file: ~/requirements.yml type: both