Commit bc630c94 authored by Rafael Monnerat's avatar Rafael Monnerat Committed by Rafael Monnerat

playbook: Fix upgrader

  In case download from shacache fails, the upgrade should safely stop and be able to run again
parent 1cd90046
...@@ -12,9 +12,9 @@ ...@@ -12,9 +12,9 @@
- file: path=/opt/upgrader/ state=directory mode=0755 - file: path=/opt/upgrader/ state=directory mode=0755
- shell: rm -rf /opt/upgrader/playbook-tmp - shell: rm -rf /opt/upgrader/tmp
- shell: mkdir -p /opt/upgrader/playbook-tmp - shell: mkdir -p /opt/upgrader/tmp
- name: Periodically download the latest playbook - name: Periodically download the latest playbook
shell: slapcache-download --destination=/opt/upgrader/archive.tar.gz shell: slapcache-download --destination=/opt/upgrader/archive.tar.gz
...@@ -22,11 +22,20 @@ ...@@ -22,11 +22,20 @@
- name: Uncompress - name: Uncompress
shell: tar -xzvf /opt/upgrader/archive.tar.gz shell: tar -xzvf /opt/upgrader/archive.tar.gz
args: args:
chdir: /opt/upgrader/playbook-tmp chdir: /opt/upgrader/tmp
- shell: cp -R /opt/upgrader/playbook-tmp /opt/upgrader/playbook - shell: cp -R /opt/upgrader/tmp /opt/upgrader/playbook
when: playbook_folder.stat.exists == False when: playbook_folder.stat.exists == False
- stat: path=/opt/upgrader/tmp/hosts
register: hosts_file
- shell: rm -rf /opt/upgrader/playbook-tmp
when: hosts.stat.exists == True
- shell: cp -R /opt/upgrader/tmp /opt/upgrader/playbook-tmp
when: hosts.stat.exists == True
- name: Save new archive MD5 - name: Save new archive MD5
stat: path=/opt/upgrader/archive.tar.gz stat: path=/opt/upgrader/archive.tar.gz
register: register:
...@@ -62,7 +71,7 @@ ...@@ -62,7 +71,7 @@
when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature')) when: (upgrade_after > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
- name: Set Cron - name: Set Cron
cron: name="Launch Upgrader with ansible" minute="0" hour="*/3" job='rm -rf /opt/upgrader/playbook && mv /opt/upgrader/playbook-tmp /opt/upgrader/playbook && cd /opt/upgrader/playbook && ansible-playbook upgrader-run.yml --extra-vars "upgrader_playbook={{ upgrader_playbook }}" -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log' cron: name="Launch Upgrader with ansible" minute="0" hour="*/3" job='rm -rf /opt/upgrader/playbook && cp -R /opt/upgrader/playbook-tmp /opt/upgrader/playbook && cd /opt/upgrader/playbook && ansible-playbook upgrader-run.yml --extra-vars "upgrader_playbook={{ upgrader_playbook }}" -i hosts 2>>/opt/upgrader/latest_upgrade.log >> /opt/upgrader/latest_upgrade.log'
- cron: name="Launch Upgrader" state=absent - cron: name="Launch Upgrader" state=absent
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment