summaryrefslogtreecommitdiff
path: root/salt/openbook/ansible/files/openbook.yaml
diff options
context:
space:
mode:
authorCarlos Konstanski <ckonstanski@pippiandcarlos.com>2017-08-30 13:09:56 -0600
committerCarlos Konstanski <ckonstanski@pippiandcarlos.com>2017-08-30 13:09:56 -0600
commit649f0dd9c5ca586d8b637400dd19c0c4059447d6 (patch)
tree5ccc992a3aa5de1bcb510911dfdb21e6a54bd197 /salt/openbook/ansible/files/openbook.yaml
initial commit
Diffstat (limited to 'salt/openbook/ansible/files/openbook.yaml')
-rw-r--r--salt/openbook/ansible/files/openbook.yaml157
1 files changed, 157 insertions, 0 deletions
diff --git a/salt/openbook/ansible/files/openbook.yaml b/salt/openbook/ansible/files/openbook.yaml
new file mode 100644
index 0000000..b6992ba
--- /dev/null
+++ b/salt/openbook/ansible/files/openbook.yaml
@@ -0,0 +1,157 @@
+---
+- name: "Install Openbook"
+ hosts: target
+ tasks:
+ - name: "Create Openbook directories"
+ file:
+ path: "{% raw %}{{ item.path }}{% endraw %}"
+ state: directory
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ with_items:
+ - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/database, mode: "0755" }
+ - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/admin_web_ui, mode: "0755" }
+ - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/api_server, mode: "0755" }
+ - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/customer_web_ui, mode: "0755" }
+ - { path: {{ pillar["database"]["dirs"]["etc_openbook_database_conf.d"]["name"] }}, mode: "0755" }
+ - { path: {{ pillar["database"]["dirs"]["etc_openbook_database_bin"]["name"] }}, mode: "0755" }
+ - { path: {{ pillar["database"]["dirs"]["var_lib_mysql"]["name"] }}, mode: "0777" }
+ - { path: {{ pillar["database"]["dirs"]["var_log_mysql"]["name"] }}, mode: "0777" }
+ - { path: {{ pillar["api_server"]["dirs"]["etc_openbook_api_server"]["name"] }}, mode: "0777" }
+ - { path: {{ pillar["customer_web_ui"]["dirs"]["etc_openbook_customer_web_ui"]["name"] }}, mode: "0777" }
+ - { path: {{ pillar["admin_web_ui"]["dirs"]["etc_openbook_admin_web_ui"]["name"] }}, mode: "0777" }
+ - { path: {{ pillar["admin_web_ui"]["log"] }}, mode: "0777" }
+ - { path: {{ pillar["api_server"]["log"] }}, mode: "0777" }
+ - { path: {{ pillar["customer_web_ui"]["log"] }}, mode: "0777" }
+
+ - name: "Create Openbook files"
+ template:
+ src: "../templates/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["openbookctl"]["path"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }}, mode: "0755" }
+ - { src: database/{{ pillar["database"]["files"]["run_sh"]["path"] }}/{{ pillar["database"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/database/{{ pillar["database"]["files"]["run_sh"]["name"] }}, mode: "0755" }
+ - { src: admin_web_ui/{{ pillar["admin_web_ui"]["files"]["run_sh"]["path"] }}/{{ pillar["admin_web_ui"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/admin_web_ui/{{ pillar["admin_web_ui"]["files"]["run_sh"]["name"] }}, mode: "0755" }
+ - { src: api_server/{{ pillar["api_server"]["files"]["run_sh"]["path"] }}/{{ pillar["api_server"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/api_server/{{ pillar["api_server"]["files"]["run_sh"]["name"] }}, mode: "0755" }
+ - { src: customer_web_ui/{{ pillar["customer_web_ui"]["files"]["run_sh"]["path"] }}/{{ pillar["customer_web_ui"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/customer_web_ui/{{ pillar["customer_web_ui"]["files"]["run_sh"]["name"] }}, mode: "0755" }
+ - { src: admin_web_ui/{{ pillar["admin_web_ui"]["files"]["admin_web_ui_json"]["path"] }}/{{ pillar["admin_web_ui"]["files"]["admin_web_ui_json"]["name"] }}, dest: {{ pillar["admin_web_ui"]["files"]["admin_web_ui_json"]["path"] }}/{{ pillar["admin_web_ui"]["files"]["admin_web_ui_json"]["name"] }}, mode: "0644" }
+ - { src: api_server/{{ pillar["api_server"]["files"]["api_server_json"]["path"] }}/{{ pillar["api_server"]["files"]["api_server_json"]["name"] }}, dest: {{ pillar["api_server"]["files"]["api_server_json"]["path"] }}/{{ pillar["api_server"]["files"]["api_server_json"]["name"] }}, mode: "0644" }
+ - { src: customer_web_ui/{{ pillar["customer_web_ui"]["files"]["customer_web_ui_json"]["path"] }}/{{ pillar["customer_web_ui"]["files"]["customer_web_ui_json"]["name"] }}, dest: {{ pillar["customer_web_ui"]["files"]["customer_web_ui_json"]["path"] }}/{{ pillar["customer_web_ui"]["files"]["customer_web_ui_json"]["name"] }}, mode: "0644" }
+ - { src: database/{{ pillar["database"]["files"]["root_my_cnf"]["path"] }}/{{ pillar["database"]["files"]["root_my_cnf"]["name"] }}, dest: {{ pillar["database"]["files"]["root_my_cnf"]["path"] }}/{{ pillar["database"]["files"]["root_my_cnf"]["name"] }}, mode: "0644" }
+ - { src: database/{{ pillar["database"]["files"]["create_openbook_schemas"]["path"] }}/{{ pillar["database"]["files"]["create_openbook_schemas"]["name"] }}, dest: {{ pillar["database"]["files"]["create_openbook_schemas"]["path"] }}/{{ pillar["database"]["files"]["create_openbook_schemas"]["name"] }}, mode: "0755" }
+ - { src: database/{{ pillar["database"]["files"]["debian_cnf"]["path"] }}/{{ pillar["database"]["files"]["debian_cnf"]["name"] }}, dest: {{ pillar["database"]["files"]["debian_cnf"]["path"] }}/{{ pillar["database"]["files"]["debian_cnf"]["name"] }}, mode: "0644" }
+ - { src: database/{{ pillar["database"]["files"]["cluster_cnf"]["path"] }}/{{ pillar["database"]["files"]["cluster_cnf"]["name"] }}, dest: {{ pillar["database"]["files"]["cluster_cnf"]["path"] }}/{{ pillar["database"]["files"]["cluster_cnf"]["name"] }}, mode: "0644" }
+ - { src: database/{{ pillar["database"]["files"]["debconfrc"]["path"] }}/{{ pillar["database"]["files"]["debconfrc"]["name"] }}, dest: {{ pillar["database"]["files"]["debconfrc"]["path"] }}/{{ pillar["database"]["files"]["debconfrc"]["name"] }}, mode: "0644" }
+ - { src: database/{{ pillar["database"]["files"]["fix_permissions_sh"]["path"] }}/{{ pillar["database"]["files"]["fix_permissions_sh"]["name"] }}, dest: {{ pillar["database"]["files"]["fix_permissions_sh"]["path"] }}/{{ pillar["database"]["files"]["fix_permissions_sh"]["name"] }}, mode: "0755" }
+ - { src: database/{{ pillar["database"]["files"]["start_galera_node_sh"]["path"] }}/{{ pillar["database"]["files"]["start_galera_node_sh"]["name"] }}, dest: {{ pillar["database"]["files"]["start_galera_node_sh"]["path"] }}/{{ pillar["database"]["files"]["start_galera_node_sh"]["name"] }}, mode: "0755" }
+
+ - name: "Create Openbook files"
+ copy:
+ src: "../files/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["cloudcfg_sh"]["path"] }}/{{ pillar["ci"]["files"]["cloudcfg_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["cloudcfg_sh"]["name"] }}, mode: "0755" }
+ - { src: database/{{ pillar["database"]["files"]["my_cnf"]["path"] }}/{{ pillar["database"]["files"]["my_cnf"]["name"] }}, dest: {{ pillar["database"]["files"]["my_cnf"]["path"] }}/{{ pillar["database"]["files"]["my_cnf"]["name"] }}, mode: "0644" }
+
+ - name: "Create Openbook init script: Ubuntu"
+ template:
+ src: "../templates/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_ubuntu"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ when: ansible_distribution == "Ubuntu"
+
+ - name: "Create Openbook init script: Redhat"
+ template:
+ src: "../templates/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_redhat"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
+
+ - name: "Create Openbook init script: Gentoo"
+ template:
+ src: "../templates/{% raw %}{{ item.src }}{% endraw %}"
+ dest: "{% raw %}{{ item.dest }}{% endraw %}"
+ mode: "{% raw %}{{ item.mode }}{% endraw %}"
+ owner: root
+ group: root
+ with_items:
+ - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" }
+ when: ansible_distribution == "Gentoo"
+
+ - name: "Add service script to systemd"
+ shell: systemctl enable openbook
+ when: ansible_distribution == "Ubuntu" or ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
+
+ - name: "Enable openbook service"
+ service:
+ name: "{% raw %}{{ item.name }}{% endraw %}"
+ enabled: yes
+ runlevel: "{% raw %}{{ item.runlevel }}{% endraw %}"
+ with_items:
+ - { name: openbook, runlevel: default }
+
+ - name: "Delete existing docker images"
+ shell: |
+ {{ pillar["ansible"]["dirs"]["output"]["name"] }}/{{ pillar["ci"]["files"]["openbookctl"]["name"] }} stop || true
+ for i in $(docker images | grep -v CREATED | awk '{print $3}'); do
+ docker rmi --force $i
+ done
+ docker container prune -f
+ ignore_errors: True
+
+ - name: "Pull docker images"
+ shell: |
+ docker login --username {{ pillar["registry"]["username"] }} --password {{ pillar["registry"]["password"] }} {{ pillar["registry"]["url"] }}
+ docker pull {{ pillar["registry"]["url"] }}/{{ pillar["database"]["image_name"] }}
+ docker pull {{ pillar["registry"]["url"] }}/{{ pillar["api_server"]["image_name"] }}
+ docker pull {{ pillar["registry"]["url"] }}/{{ pillar["admin_web_ui"]["image_name"] }}
+ docker pull {{ pillar["registry"]["url"] }}/{{ pillar["customer_web_ui"]["image_name"] }}
+
+ - name: "Write hosts entry"
+ lineinfile:
+ dest: /etc/hosts
+ regexp: "{% raw %}{{ item.regexp }}{% endraw %}"
+ line: "{% raw %}{{ item.line }}{% endraw %}"
+ with_items:
+ - { regexp: '^127\.0\.0\.1.*$', line: "127.0.0.1 localhost {% raw %}{{ ansible_nodename }}{% endraw %}" }
+
+ - name: "Install network tools"
+ apt:
+ pkg: "{% raw %}{{ item }}{% endraw %}"
+ state: present
+ with_items:
+ - netcat-openbsd
+ - lsof
+ when: ansible_distribution == "Ubuntu"
+
+ - name: "Install network tools"
+ yum:
+ name: "{% raw %}{{ item }}{% endraw %}"
+ state: present
+ with_items:
+ - nmap-ncat
+ - lsof
+ when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
+
+ - name: "Install network tools"
+ portage:
+ package: "{% raw %}{{ item }}{% endraw %}"
+ update: yes
+ changed_use: yes
+ with_items:
+ - net-analyzer/netcat
+ - sys-process/lsof
+ when: ansible_distribution == "Gentoo"