From e0a00b46493b42c10e3b0b225a3740ca3c41b733 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Tue, 16 Jun 2020 15:48:09 -0500 Subject: [PATCH] Add stop and start playbooks for nodepool Organize these like our zuul rules. Change-Id: Idf6148424c08efee9ad421b01d28d938c7058722 --- playbooks/nodepool_restart.yaml | 68 +------------------ playbooks/nodepool_start.yaml | 21 ++++++ playbooks/nodepool_stop.yaml | 30 ++++++++ .../roles/nodepool-builder/tasks/main.yaml | 6 +- .../roles/nodepool-builder/tasks/start.yaml | 4 ++ .../roles/nodepool-builder/tasks/stop.yaml | 6 ++ .../roles/nodepool-launcher/tasks/stop.yaml | 6 ++ 7 files changed, 71 insertions(+), 70 deletions(-) create mode 100644 playbooks/nodepool_start.yaml create mode 100644 playbooks/nodepool_stop.yaml create mode 100644 playbooks/roles/nodepool-builder/tasks/start.yaml create mode 100644 playbooks/roles/nodepool-builder/tasks/stop.yaml create mode 100644 playbooks/roles/nodepool-launcher/tasks/stop.yaml diff --git a/playbooks/nodepool_restart.yaml b/playbooks/nodepool_restart.yaml index 1cf35d90a3..fbc93979a7 100644 --- a/playbooks/nodepool_restart.yaml +++ b/playbooks/nodepool_restart.yaml @@ -1,68 +1,4 @@ # Run this with "-f 20" -- hosts: 'nb03.openstack.orgr:!disabled' - any_errors_fatal: true - tasks: - - name: Stop Nodepool Builder - service: - name: nodepool-builder - state: stopped - become: true - become_user: root - -- hosts: 'nodepool-builder_opendev:!disabled' - any_errors_fatal: true - tasks: - - name: Stop Nodepool builder - shell: - cmd: docker-compose down - chdir: /etc/nodepool-builder-compose - become: true - become_user: root - -- hosts: 'nodepool-launcher:!disabled' - any_errors_fatal: true - tasks: - - name: Stop Nodepool Launcher - shell: - cmd: docker-compose down - chdir: /etc/nodepool-docker/ - become: true - become_user: root - -- hosts: 'nb03.openstack.org:!disabled' - any_errors_fatal: true - tasks: - - name: Wait for (3h10m) to stop Nodepool Builder - wait_for: - path: /var/run/nodepool/nodepool-builder.pid - state: absent - timeout: 11400 - -- hosts: 'nb03.openstack.org:!disabled' - tasks: - - name: Start Nodepool Builder - service: - name: nodepool-builder - state: started - become: true - become_user: root - -- hosts: 'nodepool-builder_opendev:!disabled' - tasks: - - name: Start Nodepool Builder - shell: - cmd: docker-compose up -d - chdir: /etc/nodepool-builder-compose - become: true - become_user: root - -- hosts: 'nodepool-launcher:!disabled' - any_errors_fatal: true - tasks: - - name: Start Nodepool Launcher - shell: - cmd: docker-compose up -d - chdir: /etc/nodepool-docker/ - become: true - become_user: root +- import_playbook: nodepool_stop.yaml +- import_playbook: nodepool_start.yaml diff --git a/playbooks/nodepool_start.yaml b/playbooks/nodepool_start.yaml new file mode 100644 index 0000000000..87448deb20 --- /dev/null +++ b/playbooks/nodepool_start.yaml @@ -0,0 +1,21 @@ +# Run this with "-f 20" + +- hosts: 'nodepool-builder_opendev:!disabled' + tasks: + - include_role: + name: nodepool-builder + tasks_from: start + +- hosts: 'nodepool-launcher:!disabled' + any_errors_fatal: true + tasks: + - include_role: + name: nodepool-launcher + tasks_from: start + +- hosts: 'nb03.openstack.org:!disabled' + tasks: + - name: Start Nodepool Builder + service: + name: nodepool-builder + state: started diff --git a/playbooks/nodepool_stop.yaml b/playbooks/nodepool_stop.yaml new file mode 100644 index 0000000000..da92ec3321 --- /dev/null +++ b/playbooks/nodepool_stop.yaml @@ -0,0 +1,30 @@ +# Run this with "-f 20" + + +- hosts: 'nodepool-builder_opendev:!disabled' + any_errors_fatal: true + tasks: + - include_role: + name: nodepool-builder + tasks_from: stop + +- hosts: 'nodepool-launcher:!disabled' + any_errors_fatal: true + tasks: + - include_role: + name: nodepool-launcher + tasks_from: stop + +- hosts: 'nb03.openstack.orgr:!disabled' + any_errors_fatal: true + tasks: + - name: Stop Nodepool Builder + service: + name: nodepool-builder + state: stopped + + - name: Wait for (3h10m) to stop Nodepool Builder + wait_for: + path: /var/run/nodepool/nodepool-builder.pid + state: absent + timeout: 11400 diff --git a/playbooks/roles/nodepool-builder/tasks/main.yaml b/playbooks/roles/nodepool-builder/tasks/main.yaml index c4fe1b9adf..08eab52138 100644 --- a/playbooks/roles/nodepool-builder/tasks/main.yaml +++ b/playbooks/roles/nodepool-builder/tasks/main.yaml @@ -36,10 +36,8 @@ cmd: docker-compose pull chdir: /etc/nodepool-builder-compose/ -- name: Run docker-compose up - shell: - cmd: docker-compose up -d - chdir: /etc/nodepool-builder-compose/ +- name: Start nodepool builder + include_tasks: start.yaml - name: Run docker prune to cleanup unneeded images shell: diff --git a/playbooks/roles/nodepool-builder/tasks/start.yaml b/playbooks/roles/nodepool-builder/tasks/start.yaml new file mode 100644 index 0000000000..a58878fe09 --- /dev/null +++ b/playbooks/roles/nodepool-builder/tasks/start.yaml @@ -0,0 +1,4 @@ +- name: Run docker-compose up + shell: + cmd: docker-compose up -d + chdir: /etc/nodepool-builder-compose/ diff --git a/playbooks/roles/nodepool-builder/tasks/stop.yaml b/playbooks/roles/nodepool-builder/tasks/stop.yaml new file mode 100644 index 0000000000..710902cd41 --- /dev/null +++ b/playbooks/roles/nodepool-builder/tasks/stop.yaml @@ -0,0 +1,6 @@ +- name: Stop Nodepool builder + shell: + cmd: docker-compose down + chdir: /etc/nodepool-builder-compose + become: true + become_user: root diff --git a/playbooks/roles/nodepool-launcher/tasks/stop.yaml b/playbooks/roles/nodepool-launcher/tasks/stop.yaml new file mode 100644 index 0000000000..a91ca51841 --- /dev/null +++ b/playbooks/roles/nodepool-launcher/tasks/stop.yaml @@ -0,0 +1,6 @@ +- name: Stop Nodepool Launcher + shell: + cmd: docker-compose down + chdir: /etc/nodepool-docker/ + become: true + become_user: root