diff options
Diffstat (limited to 'deployment')
21 files changed, 156 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 }}" diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_host.stderr b/deployment/noheat/infra-openstack/vagrant/test/create_host.stderr new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_host.stderr diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_host.stdout b/deployment/noheat/infra-openstack/vagrant/test/create_host.stdout new file mode 100644 index 000000000..25c23dda2 --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_host.stdout @@ -0,0 +1 @@ +"operator0" diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_host.test b/deployment/noheat/infra-openstack/vagrant/test/create_host.test new file mode 100755 index 000000000..d36e288e9 --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_host.test @@ -0,0 +1,21 @@ +#!/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" diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stderr b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stderr new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stderr diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stdout b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stdout new file mode 100644 index 000000000..363825389 --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.stdout @@ -0,0 +1 @@ +"onap_ci_lab" diff --git a/deployment/noheat/infra-openstack/vagrant/test/create_keypair.test b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.test new file mode 100755 index 000000000..3e1dbfe2b --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/create_keypair.test @@ -0,0 +1,21 @@ +#!/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" diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stderr b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stderr new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stderr diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stdout b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stdout new file mode 100644 index 000000000..30d7e153a --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.stdout @@ -0,0 +1 @@ +Host operator0 not found. diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_host.test b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.test new file mode 100755 index 000000000..9db374e7b --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_host.test @@ -0,0 +1,21 @@ +#!/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" diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stderr b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stderr new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stderr diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stdout b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stdout new file mode 100644 index 000000000..df6e49297 --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.stdout @@ -0,0 +1 @@ +Keypair onap_ci_lab not found. diff --git a/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.test b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.test new file mode 100755 index 000000000..e80989320 --- /dev/null +++ b/deployment/noheat/infra-openstack/vagrant/test/destroy_keypair.test @@ -0,0 +1,21 @@ +#!/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" |