--- - name: "Install Openbook" hosts: target tasks: - 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" - 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 %}{{ inventory_hostname }} {{ ansible_nodename }}{% endraw %}" } - 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"] }}/job_scheduler_server, mode: "0755" } - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/workflow_server, mode: "0755" } - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/admin_api_server, mode: "0755" } - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/customer_api_server, mode: "0755" } - { path: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/admin_web_ui, 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["job_scheduler_server"]["dirs"]["etc_openbook_job_scheduler_server"]["name"] }}, mode: "0777" } - { path: {{ pillar["workflow_server"]["dirs"]["etc_openbook_workflow_server"]["name"] }}, mode: "0777" } - { path: {{ pillar["admin_api_server"]["dirs"]["etc_openbook_admin_api_server"]["name"] }}, mode: "0777" } - { path: {{ pillar["customer_api_server"]["dirs"]["etc_openbook_customer_api_server"]["name"] }}, mode: "0777" } - { path: {{ pillar["admin_web_ui"]["dirs"]["etc_openbook_admin_web_ui"]["name"] }}, mode: "0777" } - { path: {{ pillar["customer_web_ui"]["dirs"]["etc_openbook_customer_web_ui"]["name"] }}, mode: "0777" } - { path: {{ pillar["job_scheduler_server"]["log"] }}, mode: "0777" } - { path: {{ pillar["workflow_server"]["log"] }}, mode: "0777" } - { path: {{ pillar["admin_api_server"]["log"] }}, mode: "0777" } - { path: {{ pillar["customer_api_server"]["log"] }}, mode: "0777" } - { path: {{ pillar["admin_web_ui"]["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: job_scheduler_server/{{ pillar["job_scheduler_server"]["files"]["run_sh"]["path"] }}/{{ pillar["job_scheduler_server"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/job_scheduler_server/{{ pillar["job_scheduler_server"]["files"]["run_sh"]["name"] }}, mode: "0755" } - { src: workflow_server/{{ pillar["workflow_server"]["files"]["run_sh"]["path"] }}/{{ pillar["workflow_server"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/workflow_server/{{ pillar["workflow_server"]["files"]["run_sh"]["name"] }}, mode: "0755" } - { src: admin_api_server/{{ pillar["admin_api_server"]["files"]["run_sh"]["path"] }}/{{ pillar["admin_api_server"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/admin_api_server/{{ pillar["admin_api_server"]["files"]["run_sh"]["name"] }}, mode: "0755" } - { src: customer_api_server/{{ pillar["customer_api_server"]["files"]["run_sh"]["path"] }}/{{ pillar["customer_api_server"]["files"]["run_sh"]["name"] }}, dest: {{ pillar["ansible"]["dirs"]["output"]["name"] }}/customer_api_server/{{ pillar["customer_api_server"]["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: 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: job_scheduler_server/{{ pillar["job_scheduler_server"]["files"]["job_scheduler_server_json"]["path"] }}/{{ pillar["job_scheduler_server"]["files"]["job_scheduler_server_json"]["name"] }}, dest: {{ pillar["job_scheduler_server"]["files"]["job_scheduler_server_json"]["path"] }}/{{ pillar["job_scheduler_server"]["files"]["job_scheduler_server_json"]["name"] }}, mode: "0644" } - { src: workflow_server/{{ pillar["workflow_server"]["files"]["workflow_server_json"]["path"] }}/{{ pillar["workflow_server"]["files"]["workflow_server_json"]["name"] }}, dest: {{ pillar["workflow_server"]["files"]["workflow_server_json"]["path"] }}/{{ pillar["workflow_server"]["files"]["workflow_server_json"]["name"] }}, mode: "0644" } - { src: admin_api_server/{{ pillar["admin_api_server"]["files"]["admin_api_server_json"]["path"] }}/{{ pillar["admin_api_server"]["files"]["admin_api_server_json"]["name"] }}, dest: {{ pillar["admin_api_server"]["files"]["admin_api_server_json"]["path"] }}/{{ pillar["admin_api_server"]["files"]["admin_api_server_json"]["name"] }}, mode: "0644" } - { src: customer_api_server/{{ pillar["customer_api_server"]["files"]["customer_api_server_json"]["path"] }}/{{ pillar["customer_api_server"]["files"]["customer_api_server_json"]["name"] }}, dest: {{ pillar["customer_api_server"]["files"]["customer_api_server_json"]["path"] }}/{{ pillar["customer_api_server"]["files"]["customer_api_server_json"]["name"] }}, mode: "0644" } - { 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: 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_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" } - { src: ci/{{ pillar["ci"]["files"]["openbook_ubuntu_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_ubuntu_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, 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_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" } - { src: ci/{{ pillar["ci"]["files"]["openbook_redhat_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_redhat_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, 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_openrc_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_start"]["name"] }}, dest: /etc/init.d/openbook, mode: "0755" } - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_openrc_debug"]["name"] }}, dest: /etc/init.d/openbook-debug, mode: "0755" } when: ansible_distribution == "Gentoo" and ansible_service_mgr == "openrc" - name: "Create Openbook systemd scripts: 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_systemd_start"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_start"]["name"] }}, dest: /etc/systemd/system/openbook.service, mode: "0644" } - { src: ci/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_debug"]["path"] }}/{{ pillar["ci"]["files"]["openbook_gentoo_systemd_debug"]["name"] }}, dest: /etc/systemd/system/openbook-debug.service, mode: "0644" } when: ansible_distribution == "Gentoo" and ansible_service_mgr == "systemd" - name: "Add service script to systemd" shell: systemctl enable openbook.service with_items: - openbook when: ansible_distribution == "Ubuntu" or ansible_distribution == "RedHat" or ansible_distribution == "CentOS" or (ansible_distribution == "Gentoo" and ansible_service_mgr == "systemd") - name: "Enable openbook service" service: name: "{% raw %}{{ item.name }}{% endraw %}" enabled: yes runlevel: "{% raw %}{{ item.runlevel }}{% endraw %}" with_items: - { name: openbook, runlevel: default } when: openbook_install_database|string() == "False" - name: "Disable openbook service" service: name: "{% raw %}{{ item.name }}{% endraw %}" enabled: no runlevel: "{% raw %}{{ item.runlevel }}{% endraw %}" with_items: - { name: openbook, runlevel: default } when: openbook_install_database|string() == "True" - name: "Stop Openbook" include: stop_start_openbook.yaml action=stop - name: "Install Openbook" hosts: target tasks: - 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 "{% raw %}{{ openbook_docker_registry_username }}{% endraw %}" --password "{% raw %}{{ openbook_docker_registry_password }}{% endraw %}" "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}" if [ "{% raw %}{{ openbook_install_database|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["database"]["image_name"] }}" fi if [ "{% raw %}{{ openbook_install_job_scheduler_server|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["job_scheduler_server"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi if [ "{% raw %}{{ openbook_install_workflow_server|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["workflow_server"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi if [ "{% raw %}{{ openbook_install_admin_api_server|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["admin_api_server"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi if [ "{% raw %}{{ openbook_install_customer_api_server|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["customer_api_server"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi if [ "{% raw %}{{ openbook_install_admin_web_ui|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["admin_web_ui"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi if [ "{% raw %}{{ openbook_install_customer_web_ui|string() }}{% endraw %}" == "True" ]; then docker pull "{% raw %}{{ openbook_docker_registry_url }}{% endraw %}/{{ pillar["customer_web_ui"]["image_name"] }}_{% raw %}{{ openbook_branch }}{% endraw %}" fi args: executable: /bin/bash - name: "Start Openbook" include: stop_start_openbook.yaml action=start extra_args=""