I have an ansible playbook which looks roughly like the following. I need Zero Downtime Upgrade start and Zero Downtime Upgrade completed steps. will run once to put\remove cluser into upgrade mode. in addition I need all the tasks into Block will be run only on one node on same time and continue to next node once we get HTTP 200
Could you please review the yml file ? currently I get ERROR! 'uri' is not a valid attribute for a Block and if you have any suggestion to improve it.
---
- name: Zero Downtime Upgrade start
hosts: atl
serial: 1
gather_facts: false
vars_files:
vars.yml
tasks:
- name: get Cluster state
run_once: true
uri:
url: https://{{ base_url }}.XXX.com/rest/api/2/cluster/zdu/state
headers:
Content-Type: application/json
force_basic_auth: true
validate_certs: false
user: XXX
password: XXX
register: response
# - name: debug.
# debug: var=response
# run_once: true
- name: trigger Zero Downtime upgrade API
run_once: true
uri:
url: https://{{ base_url }}.XXX.com/rest/api/2/cluster/zdu/start
method: POST
validate_certs: false
headers:
Content-Type: application/json
force_basic_auth: true
user: XXX
password: XXX
status_code: 201
# register: response
when: response.json.state == 'STABLE'
# - name: debug.
# run_once: true
# debug: var=response
- block:
- name: create dir for backup configuration
file:
path: "{{ atl_backup_conf }}"
state: directory
mode: '0755'
owner: atl
group: atl
- name: backup configuration files
copy:
src: "{{ item }}"
dest: "{{ atl_backup_conf }}"
# backup: true
remote_src: true
owner: atl
group: atl
with_items:
- "{{ atl_app }}/bin/setenv.sh"
ignore_errors: true
- name: "stop atl service on {{ ansible_hostname }} atl node"
#shell: /etc/init.d/atl stop
systemd:
name: atl
state: stopped
become: yes
- name: Zero Downtime Upgrade completed steps.
hosts: atl
vars_files:
vars.yml
tasks:
- name: trigger Zero Downtime upgrade API change to Stable status.
run_once: true
uri:
url: https://{{ base_url }}.XXX.com/rest/api/2/cluster/zdu/approve
method: POST
validate_certs: false
headers:
Content-Type: application/json
force_basic_auth: true
user: XXX
password: XXX
status_code: 409 , 200