gather_facts: False
roles:
- openstack/create_devstack_network
+ - openstack/create_devstack_keypair
+ - openstack/create_devstack_hosts
connection: local
gather_facts: False
roles:
+ - openstack/destroy_devstack_hosts
+ - openstack/destroy_devstack_keypair
- openstack/destroy_devstack_network
---
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
--- /dev/null
+---
+- name: Create host
+ os_server:
+ state: present
+ name: "{{ host.name }}"
+ image: "{{ host.image }}"
+ flavor: "{{ host.flavor }}"
+ key_name: "{{ host.keypair }}"
+ network: "{{ host.network }}"
--- /dev/null
+---
+- include: create_host.yml host={{ item }}
+ with_items:
+ - "{{ hosts }}"
--- /dev/null
+- 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
--- /dev/null
+---
+- name: Destroy host
+ os_server:
+ name: "{{ host.name }}"
+ state: absent
--- /dev/null
+---
+- include: destroy_host.yml host={{ item }}
+ with_items:
+ - "{{ hosts }}"
--- /dev/null
+- 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 }}"
--- /dev/null
+"operator0"
--- /dev/null
+#!/bin/sh
+
+export HOST_NAME='operator0'
+
+export VAGRANT_CWD='..'
+
+set_up() {
+ vagrant up --provision-with=run_playbook_destroy
+ vagrant up --provision-with=run_playbook_create
+}
+
+check() {
+ local host="$1"
+ vagrant ssh operator --no-tty -c \
+ "export OS_CLOUD=openstack; openstack server list -fcsv" \
+ | grep "$host" \
+ | cut -d',' -f2
+}
+
+set_up >/dev/null # drop provisioning output
+check "$HOST_NAME"
--- /dev/null
+"onap_ci_lab"
--- /dev/null
+#!/bin/sh
+
+export KEYPAIR_NAME='onap_ci_lab'
+
+export VAGRANT_CWD='..'
+
+set_up() {
+ vagrant up --provision-with=run_playbook_destroy
+ vagrant up --provision-with=run_playbook_create
+}
+
+check() {
+ local key="$1"
+ vagrant ssh operator --no-tty -c \
+ "export OS_CLOUD=openstack; openstack keypair list -fcsv" \
+ | grep "$key" \
+ | cut -d',' -f1
+}
+
+set_up >/dev/null # drop provisioning output
+check "$KEYPAIR_NAME"
--- /dev/null
+Host operator0 not found.
--- /dev/null
+#!/bin/sh
+
+export HOST_NAME='operator0'
+
+export VAGRANT_CWD='..'
+
+set_up() {
+ vagrant up --provision-with=run_playbook_create
+ vagrant up --provision-with=run_playbook_destroy
+}
+
+check() {
+ local host="$1"
+ vagrant ssh operator --no-tty -c \
+ "export OS_CLOUD=openstack; openstack server list -fcsv" \
+ | grep "$host" \
+ || echo "Host ${host} not found."
+}
+
+set_up >/dev/null # drop provisioning output
+check "$HOST_NAME"
--- /dev/null
+Keypair onap_ci_lab not found.
--- /dev/null
+#!/bin/sh
+
+export KEYPAIR_NAME='onap_ci_lab'
+
+export VAGRANT_CWD='..'
+
+set_up() {
+ vagrant up --provision-with=run_playbook_create
+ vagrant up --provision-with=run_playbook_destroy
+}
+
+check() {
+ local key="$1"
+ vagrant ssh operator --no-tty -c \
+ "export OS_CLOUD=openstack; openstack keypair list -fcsv" \
+ | grep "$key" \
+ || echo "Keypair ${key} not found."
+}
+
+set_up >/dev/null # drop provisioning output
+check "$KEYPAIR_NAME"