aboutsummaryrefslogtreecommitdiffstats
path: root/deployment/noheat/infra-openstack/ansible
diff options
context:
space:
mode:
authorPawel Wieczorek <p.wieczorek2@samsung.com>2020-06-16 12:05:14 +0200
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>2020-07-30 09:03:11 +0000
commitcbc0bf009dc59c483c88ce32a50c016874cd5363 (patch)
tree0fe5634bc0dc230a03d3e860267c9c3cd09b5c7f /deployment/noheat/infra-openstack/ansible
parenta879e2a54e0641b692202d417021f1824032b123 (diff)
Add Ansible roles for OpenStack hosts
Key pair is generated upon host creation and removed after the host is destroyed. This patch is based on previous work by: Krzysztof Opasiak <k.opasiak@samsung.com> Issue-ID: INT-1601 Change-Id: I9acd0b68a3ee79a0d710c40e0a1cc8470dfacce5 Signed-off-by: Pawel Wieczorek <p.wieczorek2@samsung.com>
Diffstat (limited to 'deployment/noheat/infra-openstack/ansible')
-rw-r--r--deployment/noheat/infra-openstack/ansible/create.yml2
-rw-r--r--deployment/noheat/infra-openstack/ansible/destroy.yml2
-rw-r--r--deployment/noheat/infra-openstack/ansible/group_vars/all.yml12
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/create_host.yml9
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/main.yml4
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml19
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/destroy_host.yml5
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/main.yml4
-rw-r--r--deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_keypair/tasks/main.yml12
9 files changed, 68 insertions, 1 deletions
diff --git a/deployment/noheat/infra-openstack/ansible/create.yml b/deployment/noheat/infra-openstack/ansible/create.yml
index dd21271b2..a2665f911 100644
--- a/deployment/noheat/infra-openstack/ansible/create.yml
+++ b/deployment/noheat/infra-openstack/ansible/create.yml
@@ -5,3 +5,5 @@
gather_facts: False
roles:
- openstack/create_devstack_network
+ - openstack/create_devstack_keypair
+ - openstack/create_devstack_hosts
diff --git a/deployment/noheat/infra-openstack/ansible/destroy.yml b/deployment/noheat/infra-openstack/ansible/destroy.yml
index b63e07088..4576125c4 100644
--- a/deployment/noheat/infra-openstack/ansible/destroy.yml
+++ b/deployment/noheat/infra-openstack/ansible/destroy.yml
@@ -4,4 +4,6 @@
connection: local
gather_facts: False
roles:
+ - openstack/destroy_devstack_hosts
+ - openstack/destroy_devstack_keypair
- openstack/destroy_devstack_network
diff --git a/deployment/noheat/infra-openstack/ansible/group_vars/all.yml b/deployment/noheat/infra-openstack/ansible/group_vars/all.yml
index 68497a0a5..1da1e8f78 100644
--- a/deployment/noheat/infra-openstack/ansible/group_vars/all.yml
+++ b/deployment/noheat/infra-openstack/ansible/group_vars/all.yml
@@ -1,4 +1,14 @@
---
network:
- name: "onap_ci_lab"
+ name: &network_name "onap_ci_lab"
cidr: "192.168.1.0/24"
+
+keypair:
+ name: &keypair_name "onap_ci_lab"
+
+hosts:
+ - name: "operator0"
+ image: "cirros-0.5.1-x86_64-disk"
+ flavor: "cirros256"
+ keypair: *keypair_name
+ network: *network_name
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/create_host.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/create_host.yml
new file mode 100644
index 000000000..847150f36
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/create_host.yml
@@ -0,0 +1,9 @@
+---
+- name: Create host
+ os_server:
+ state: present
+ name: "{{ host.name }}"
+ image: "{{ host.image }}"
+ flavor: "{{ host.flavor }}"
+ key_name: "{{ host.keypair }}"
+ network: "{{ host.network }}"
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/main.yml
new file mode 100644
index 000000000..f79314c72
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_hosts/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- include: create_host.yml host={{ item }}
+ with_items:
+ - "{{ hosts }}"
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml
new file mode 100644
index 000000000..4ac8a48f1
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/create_devstack_keypair/tasks/main.yml
@@ -0,0 +1,19 @@
+- name: Create keypair
+ os_keypair:
+ state: present
+ name: "{{ keypair.name }}"
+ register: keypair
+
+- name: Create local public key
+ local_action:
+ module: copy
+ content: "{{ keypair.key.public_key }}"
+ dest: "~/.ssh/{{ keypair.key.name }}.pub"
+ mode: 0600
+
+- name: Create local private key
+ local_action:
+ module: copy
+ content: "{{ keypair.key.private_key }}"
+ dest: "~/.ssh/{{ keypair.key.name }}"
+ mode: 0600
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/destroy_host.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/destroy_host.yml
new file mode 100644
index 000000000..e9cedce7a
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/destroy_host.yml
@@ -0,0 +1,5 @@
+---
+- name: Destroy host
+ os_server:
+ name: "{{ host.name }}"
+ state: absent
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/main.yml
new file mode 100644
index 000000000..eddf09736
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_hosts/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+- include: destroy_host.yml host={{ item }}
+ with_items:
+ - "{{ hosts }}"
diff --git a/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_keypair/tasks/main.yml b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_keypair/tasks/main.yml
new file mode 100644
index 000000000..b106ee0cd
--- /dev/null
+++ b/deployment/noheat/infra-openstack/ansible/roles/openstack/destroy_devstack_keypair/tasks/main.yml
@@ -0,0 +1,12 @@
+- name: Destroy keypair
+ os_keypair:
+ state: absent
+ name: "{{ keypair.name }}"
+
+- name: Destroy local keypair
+ file:
+ state: absent
+ path: "{{ item }}"
+ with_items:
+ - "~/.ssh/{{ keypair.name }}.pub"
+ - "~/.ssh/{{ keypair.name }}"