ansible profile
Change-Id: I6c577b6852b4b53812c4ddca6dc83b042caefe30
diff --git a/cord-pod-ansible/roles/bootstrap/defaults/main.yml b/cord-pod-ansible/roles/bootstrap/defaults/main.yml
new file mode 100644
index 0000000..c466b16
--- /dev/null
+++ b/cord-pod-ansible/roles/bootstrap/defaults/main.yml
@@ -0,0 +1,7 @@
+fixtures_yml: "{{ config_dir }}/../common/fixtures.yaml"
+
+mydeployment_yml: "{{ config_dir }}/../common/mydeployment.yaml"
+
+bootstrap_yml: "{{ config_dir }}/docker-compose-bootstrap.yml"
+
+xos_tosca_yml: "{{ config_dir }}/xos.yaml"
diff --git a/cord-pod-ansible/roles/bootstrap/tasks/main.yml b/cord-pod-ansible/roles/bootstrap/tasks/main.yml
new file mode 100644
index 0000000..b1a2e03
--- /dev/null
+++ b/cord-pod-ansible/roles/bootstrap/tasks/main.yml
@@ -0,0 +1,32 @@
+---
+
+- name: remove old docker-compose-bootstrap file
+ file:
+ path=onboarding-docker-compose/docker-compose.yml
+ state=absent
+
+- name: run docker-compose to start bootstrapping
+ shell: CONFIG_DIR={{ config_dir }} docker-compose -p {{ bootstrap_project }} -f {{ bootstrap_yml }} up -d
+ chdir={{ config_dir }}
+ sudo: true
+
+- name: wait for XOS bootstrap_ui to come online
+ uri:
+ url: "http://0.0.0.0:{{ bootstrap_port }}/"
+ register: result
+ retries: 120
+ delay: 1
+ until: result['status']|default(0)==200
+
+- name: add fixtures
+ shell: docker-compose -p {{ bootstrap_project }} -f {{ bootstrap_yml }} run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < {{ fixtures_yml }}
+
+- name: add mydeployment
+ shell: docker-compose -p {{ bootstrap_project }} -f {{ bootstrap_yml }} run xos_bootstrap_ui python /opt/xos/tosca/run.py none - < {{ mydeployment_yml }}
+
+- name: run tosca recipe xos.yaml
+ xostosca:
+ port={{ bootstrap_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', xos_tosca_yml) }}
diff --git a/cord-pod-ansible/roles/buildconfig/tasks/main.yml b/cord-pod-ansible/roles/buildconfig/tasks/main.yml
new file mode 100644
index 0000000..26907d3
--- /dev/null
+++ b/cord-pod-ansible/roles/buildconfig/tasks/main.yml
@@ -0,0 +1,13 @@
+---
+
+- name: make nodes.yaml
+ shell: export SETUPDIR={{ setup_dir }}; bash {{ config_dir }}/../common/make-nodes-yaml.sh
+
+- name: make images.yaml
+ shell: export SETUPDIR={{ setup_dir }}; bash {{ config_dir }}/../common/make-images-yaml.sh
+
+- name: make vtn-external.yaml
+ shell: export SETUPDIR={{ setup_dir }}; bash {{ config_dir }}/scripts/make-vtn-external-yaml.sh
+
+- name: make fabric.yaml
+ shell: export SETUPDIR={{ setup_dir }}; bash {{ config_dir }}/scripts/make-fabric-yaml.sh
diff --git a/cord-pod-ansible/roles/config/tasks/main.yml b/cord-pod-ansible/roles/config/tasks/main.yml
new file mode 100644
index 0000000..3016471
--- /dev/null
+++ b/cord-pod-ansible/roles/config/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+
+- name: run config recipe {{ item.name }}
+ xostosca:
+ port={{ ui_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', item.yaml) }}
+ with_items: "{{ config_recipes | default([]) }}"
diff --git a/cord-pod-ansible/roles/download_images/defaults/main.yml b/cord-pod-ansible/roles/download_images/defaults/main.yml
new file mode 100644
index 0000000..9f2cbbc
--- /dev/null
+++ b/cord-pod-ansible/roles/download_images/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+
+image_temp_dir: "{{ config_dir }}/images_staging"
+image_dest_dir: "{{ config_dir }}/images"
diff --git a/cord-pod-ansible/roles/download_images/tasks/main.yml b/cord-pod-ansible/roles/download_images/tasks/main.yml
new file mode 100644
index 0000000..cbc83a8
--- /dev/null
+++ b/cord-pod-ansible/roles/download_images/tasks/main.yml
@@ -0,0 +1,20 @@
+---
+
+- name: check image existence
+ command: "bash -c \"source {{ setup_dir }}/admin-openrc.sh; glance image-show {{ item.name }}\""
+ ignore_errors: yes
+ register: checked_images
+ with_items: "{{ images | default([]) }}"
+
+- name: download images
+ get_url:
+ url={{ item.item.url }}
+ dest={{ image_dest_dir }}/{{ item.item.filename }}
+ tmp_dest={{ image_temp_dir }}
+ when: item.rc != 0
+ with_items: "{{ checked_images.results | default([]) }}"
+
+- name: add images to glance
+ command: "bash -c \"source {{ setup_dir }}/admin-openrc.sh; glance image-create --name {{ item.item.name }} --disk-format qcow2 --file ./images/{{ item.item.filename }} --container-format bare\""
+ when: item.rc != 0
+ with_items: "{{ checked_images.results | default([]) }}"
diff --git a/cord-pod-ansible/roles/local_containers/tasks/main.yml b/cord-pod-ansible/roles/local_containers/tasks/main.yml
new file mode 100644
index 0000000..91ea3c3
--- /dev/null
+++ b/cord-pod-ansible/roles/local_containers/tasks/main.yml
@@ -0,0 +1,4 @@
+---
+
+- name: build local containers
+ shell: make -f {{ config_dir }}/../common/Makefile.containers update_certs xos_base xos_devel synchronizer onboarding_synchronizer
diff --git a/cord-pod-ansible/roles/local_environment/tasks/main.yml b/cord-pod-ansible/roles/local_environment/tasks/main.yml
new file mode 100644
index 0000000..84890ff
--- /dev/null
+++ b/cord-pod-ansible/roles/local_environment/tasks/main.yml
@@ -0,0 +1,41 @@
+---
+- name: create key_import directory
+ file:
+ name=key_import
+ state=directory
+
+- name: create onboarding-docker-compose directory
+ file:
+ name=onboarding-docker-compose
+ state=directory
+
+- name: create images directory
+ file:
+ name=images
+ state=directory
+
+- name: create images_staging directory
+ file:
+ name=images_staging
+ state=directory
+
+- name: download xos from repo
+ git:
+ repo={{ xos_repo }}
+ dest={{ xos_core_dir }}
+
+- name: download xos services
+ git:
+ repo="{{ item.repo }}"
+ dest="{{ xos_services_dir }}/{{ item.name }}"
+ with_items:
+ - { name: "exampleservice", repo: "https://gerrit.opencord.org/p/exampleservice.git" }
+ - { name: "olt", repo: "https://gerrit.opencord.org/p/olt.git" }
+ - { name: "vsg", repo: "https://gerrit.opencord.org/p/vsg.git" }
+ - { name: "vtn", repo: "https://gerrit.opencord.org/p/vtn.git" }
+ - { name: "vrouter", repo: "https://gerrit.opencord.org/p/vrouter.git" }
+ - { name: "vtr", repo: "https://gerrit.opencord.org/p/vtr.git" }
+ - { name: "onos-service", repo: "https://gerrit.opencord.org/p/onos-service.git" }
+ - { name: "fabric", repo: "https://gerrit.opencord.org/p/fabric.git" }
+ - { name: "monitoring", repo: "https://gerrit.opencord.org/p/monitoring.git" }
+
\ No newline at end of file
diff --git a/cord-pod-ansible/roles/onboarding/defaults/main.yml b/cord-pod-ansible/roles/onboarding/defaults/main.yml
new file mode 100644
index 0000000..e7b4212
--- /dev/null
+++ b/cord-pod-ansible/roles/onboarding/defaults/main.yml
@@ -0,0 +1,6 @@
+---
+
+disable_onboarding_tosca_yml: "{{ config_dir }}/../common/disable-onboarding.yaml"
+enable_onboarding_tosca_yml: "{{ config_dir }}/../common/enable-onboarding.yaml"
+
+# onboard_services:
diff --git a/cord-pod-ansible/roles/onboarding/tasks/main.yml b/cord-pod-ansible/roles/onboarding/tasks/main.yml
new file mode 100644
index 0000000..592d4b7
--- /dev/null
+++ b/cord-pod-ansible/roles/onboarding/tasks/main.yml
@@ -0,0 +1,77 @@
+---
+
+#- name: disable onboarding
+# uri:
+# url="http://127.0.0.1:{{ bootstrap_port }}/utility/tosca/run"
+# user={{ bootstrap_user }}
+# password={{ bootstrap_password }}
+# body= {{ "{" }} 'recipe': {{ lookup('file', disable_tosca_yaml) }} {{ "}" }}
+
+- name: disable onboarding
+ xostosca:
+ port={{ bootstrap_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', disable_onboarding_tosca_yml) }}
+
+- name: install private keys
+ copy:
+ dest="{{ key_import_dir }}/{{ item.name }}"
+ src="{{ item.private_fn }}"
+ with_items: "{{ onboard_keys | default([]) }}"
+
+- name: install public keys
+ copy:
+ dest="{{ key_import_dir }}/{{ item.name }}.pub"
+ src="{{ item.public_fn }}"
+ with_items: "{{ onboard_keys | default([]) }}"
+
+- name: onboard services
+ xostosca:
+ port={{ bootstrap_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', item.yaml) }}
+ with_items: "{{ onboard_services | default([]) }}"
+
+- name: run synchronizers.yml tosca recipe
+ xostosca:
+ port={{ bootstrap_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', synchronizers_yml) }}
+ when: synchronizers_yml is defined
+
+- name: enable onboarding
+ xostosca:
+ port={{ bootstrap_port }}
+ username={{ bootstrap_user }}
+ password={{ bootstrap_password }}
+ recipe={{ lookup('file', enable_onboarding_tosca_yml) }}
+
+- name: wait for onboarding ready for service {{ item.name }}
+ uri:
+ url: "http://0.0.0.0:{{ bootstrap_port }}/api/utility/onboarding/services/{{ item.name }}/ready/"
+ return_content: true
+ register: result
+ retries: 60
+ delay: 5
+ until: result.content=="true"
+ with_items: "{{ onboard_services | default([]) }}"
+
+- name: wait for onboarding ready for xos core
+ uri:
+ url: "http://0.0.0.0:{{ bootstrap_port }}/api/utility/onboarding/xos/ready/"
+ return_content: true
+ register: result
+ retries: 60
+ delay: 5
+ until: result.content=="true"
+
+- name: wait for XOS ui to come online
+ uri:
+ url: "http://0.0.0.0:{{ ui_port }}/"
+ register: result
+ retries: 120
+ delay: 1
+ until: result['status']|default(0)==200
diff --git a/cord-pod-ansible/roles/prereqs/tasks/main.yml b/cord-pod-ansible/roles/prereqs/tasks/main.yml
new file mode 100644
index 0000000..c8a2249
--- /dev/null
+++ b/cord-pod-ansible/roles/prereqs/tasks/main.yml
@@ -0,0 +1,25 @@
+---
+# tasks for prereqs
+
+- name: install httpie
+ apt:
+ pkg=httpie
+
+- name: install curl
+ apt:
+ pkg=curl
+
+- name: is docker installed
+ command: which docker
+ register: docker_installed
+
+- name: install docker
+ command: wget wget -qO- https://get.docker.com/ | sh
+ when: docker_installed.rc != 0
+
+# XXX fixme -- current username is hardcoded to ubuntu
+
+- name: add user to docker group
+ user:
+ name=ubunu
+ groups=docker
diff --git a/cord-pod-ansible/roles/rm/defaults/main.yml b/cord-pod-ansible/roles/rm/defaults/main.yml
new file mode 100644
index 0000000..5ac6217
--- /dev/null
+++ b/cord-pod-ansible/roles/rm/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+
+bootstrap_yml: "{{ config_dir }}/docker-compose-bootstrap.yml"
+docker_compose_yml: "{{ config_dir }}/onboarding-docker-compose/docker-compose.yml"
diff --git a/cord-pod-ansible/roles/rm/tasks/main.yml b/cord-pod-ansible/roles/rm/tasks/main.yml
new file mode 100644
index 0000000..e18b059
--- /dev/null
+++ b/cord-pod-ansible/roles/rm/tasks/main.yml
@@ -0,0 +1,12 @@
+---
+
+- name: check to see if onboarding yaml is present
+ stat: path=onboarding-docker-compose/docker-compose.yml
+ register: onboarding_compose
+
+- name: stop onboarded containers
+ shell: docker-compose -p {{ docker_project }} -f {{ docker_compose_yml }} rm -f
+ when: onboarding_compose.stat.exists == True
+
+- name: stop bootstrap containers
+ shell: docker-compose -p {{ bootstrap_project }} -f {{ bootstrap_yml }} rm -f
diff --git a/cord-pod-ansible/roles/stop/defaults/main.yml b/cord-pod-ansible/roles/stop/defaults/main.yml
new file mode 100644
index 0000000..5ac6217
--- /dev/null
+++ b/cord-pod-ansible/roles/stop/defaults/main.yml
@@ -0,0 +1,4 @@
+---
+
+bootstrap_yml: "{{ config_dir }}/docker-compose-bootstrap.yml"
+docker_compose_yml: "{{ config_dir }}/onboarding-docker-compose/docker-compose.yml"
diff --git a/cord-pod-ansible/roles/stop/tasks/main.yml b/cord-pod-ansible/roles/stop/tasks/main.yml
new file mode 100644
index 0000000..89072f6
--- /dev/null
+++ b/cord-pod-ansible/roles/stop/tasks/main.yml
@@ -0,0 +1,12 @@
+---
+
+- name: check to see if onboarding yaml is present
+ stat: path=onboarding-docker-compose/docker-compose.yml
+ register: onboarding_compose
+
+- name: stop onboarded containers
+ shell: docker-compose -p {{ docker_project }} -f {{ docker_compose_yml }} stop
+ when: onboarding_compose.stat.exists == True
+
+- name: stop bootstrap containers
+ shell: docker-compose -p {{ bootstrap_project }} -f {{ bootstrap_yml }} stop