diff options
Diffstat (limited to 'deployment/noheat/infra-openstack/ansible/roles/create_hosts')
-rw-r--r-- | deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/create_host.yml | 33 | ||||
-rw-r--r-- | deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/main.yml | 3 |
2 files changed, 36 insertions, 0 deletions
diff --git a/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/create_host.yml b/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/create_host.yml new file mode 100644 index 000000000..c217abaa9 --- /dev/null +++ b/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/create_host.yml @@ -0,0 +1,33 @@ +--- +- name: Create host + os_server: + state: present + name: "{{ host.name }}" + image: "{{ host.image }}" + flavor: "{{ host.flavor }}" + key_name: "{{ host.keypair }}" + network: "{{ host.network }}" + security_groups: + - "{{ host.securitygroup }}" + auto_ip: "{{ host.auto_ip | default(true) }}" + boot_from_volume: true + terminate_volume: true + volume_size: "{{ host.volume_size | default(10) }}" + userdata: | + #cloud-config + ssh_authorized_keys: + - "{{ operator_key }}" + register: new_host + +- name: Add host to inventory + add_host: + hostname: "{{ new_host.server.name }}" + groups: "{{ cluster.name }}" + ansible_ssh_host: "{{ new_host.server.public_v4 }}" + ansible_ssh_user: "{{ image.user }}" + ansible_ssh_extra_args: "-o StrictHostKeyChecking=no" + ansible_ssh_private_key_file: "~/.ssh/{{ keypair.key.name }}" + +- name: Add host to hosts dict + set_fact: + hosts_dict: "{{ hosts_dict|default({}) | combine( {new_host.server.name: new_host.server.private_v4} ) }}" diff --git a/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/main.yml new file mode 100644 index 000000000..731bca04f --- /dev/null +++ b/deployment/noheat/infra-openstack/ansible/roles/create_hosts/tasks/main.yml @@ -0,0 +1,3 @@ +--- +- include: create_host.yml host={{ item }} + loop: "{{ hosts }}" |