Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 1 | # Copyright (c) 2022 VEXXHOST, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
Mohammed Naser | 206e5f8 | 2022-03-16 20:21:14 -0400 | [diff] [blame] | 15 | - import_playbook: vexxhost.atmosphere.generate_secrets |
| 16 | vars: |
| 17 | secrets_path: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/secrets.yml" |
| 18 | |
Mohammed Naser | 336caf4 | 2022-03-11 17:56:45 -0500 | [diff] [blame] | 19 | - hosts: localhost |
| 20 | connection: local |
| 21 | gather_facts: false |
| 22 | no_log: "{{ molecule_no_log }}" |
| 23 | vars: |
| 24 | ssh_port: 22 |
| 25 | stack_name: "{{ lookup('env', 'STACK_NAME') | default('atmosphere', True) }}" |
| 26 | identity_file: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}/id_rsa" |
| 27 | tasks: |
| 28 | - name: create stack |
| 29 | openstack.cloud.stack: |
| 30 | name: "{{ stack_name }}" |
| 31 | template: heat/stack.yaml |
| 32 | register: _os_stack |
| 33 | |
| 34 | - debug: |
| 35 | msg: "{{ _os_stack.stack }}" |
| 36 | |
| 37 | - name: grab list of all ip addresses |
| 38 | ansible.builtin.set_fact: |
| 39 | key_pair: "{{ _os_stack.stack.outputs | json_query(key_query) | first }}" |
| 40 | controller_ips: "{{ _os_stack.stack.outputs | community.general.json_query(controller_query) | first }}" |
| 41 | storage_ips: "{{ _os_stack.stack.outputs | community.general.json_query(storage_query) | first }}" |
| 42 | compute_ips: "{{ _os_stack.stack.outputs | community.general.json_query(compute_query) | first }}" |
| 43 | vars: |
| 44 | key_query: "[?output_key=='key_pair'].output_value" |
| 45 | controller_query: "[?output_key=='controller_floating_ip_addresses'].output_value" |
| 46 | storage_query: "[?output_key=='storage_floating_ip_addresses'].output_value" |
| 47 | compute_query: "[?output_key=='compute_floating_ip_addresses'].output_value" |
| 48 | |
| 49 | - name: wait for systems to go up |
| 50 | ansible.builtin.wait_for: |
| 51 | port: "22" |
| 52 | host: "{{ item }}" |
| 53 | search_regex: SSH |
| 54 | timeout: 60 |
| 55 | loop: "{{ controller_ips + storage_ips + compute_ips }}" |
| 56 | |
| 57 | - name: generate private key file |
| 58 | ansible.builtin.copy: |
| 59 | dest: "{{ identity_file }}" |
| 60 | content: "{{ key_pair }}" |
| 61 | mode: 0600 |
| 62 | |
| 63 | - name: generate instance config file |
| 64 | copy: |
| 65 | content: "{{ instance_config | to_yaml }}" |
| 66 | dest: "{{ molecule_instance_config }}" |
| 67 | vars: |
| 68 | base_instance_config: &instance_config |
| 69 | user: "ubuntu" |
| 70 | port: "{{ ssh_port }}" |
| 71 | identity_file: "{{ identity_file }}" |
| 72 | instance_config: |
| 73 | - <<: *instance_config |
| 74 | instance: "ctl1" |
| 75 | address: "{{ controller_ips[0] }}" |
| 76 | - <<: *instance_config |
| 77 | instance: "ctl2" |
| 78 | address: "{{ controller_ips[1] }}" |
| 79 | - <<: *instance_config |
| 80 | instance: "ctl3" |
| 81 | address: "{{ controller_ips[2] }}" |
| 82 | - <<: *instance_config |
| 83 | instance: "nvme1" |
| 84 | address: "{{ storage_ips[0] }}" |
| 85 | - <<: *instance_config |
| 86 | instance: "nvme2" |
| 87 | address: "{{ storage_ips[1] }}" |
| 88 | - <<: *instance_config |
| 89 | instance: "nvme3" |
| 90 | address: "{{ storage_ips[2] }}" |
| 91 | - <<: *instance_config |
| 92 | instance: "kvm1" |
| 93 | address: "{{ compute_ips[0] }}" |
| 94 | - <<: *instance_config |
| 95 | instance: "kvm2" |
Mohammed Naser | 206e5f8 | 2022-03-16 20:21:14 -0400 | [diff] [blame] | 96 | address: "{{ compute_ips[1] }}" |