Commit 35824342 authored by Rafael Monnerat's avatar Rafael Monnerat

playbook: Introduce timebased upgrade schedule

Now 'upgrader' should do also date comparation.
parent db0d2246
--- ---
- stat: path=/opt/upgrader/last-upgrade
register: last_upgrade
- shell: echo 1 > /opt/upgrader/last-upgrade
when: last_upgrade.stat.exists == False
- file: path=/opt/upgrader/ state=directory mode=0755 - file: path=/opt/upgrader/ state=directory mode=0755
- shell: rm -rf /opt/upgrader/playbook/ - shell: rm -rf /opt/upgrader/playbook/
...@@ -34,13 +40,16 @@ ...@@ -34,13 +40,16 @@
- name: Do upgrade - name: Do upgrade
shell: ansible-playbook {{ upgrader_playbook }} -i hosts >> /opt/upgrader/latest_upgrade.log shell: ansible-playbook {{ upgrader_playbook }} -i hosts >> /opt/upgrader/latest_upgrade.log
when: 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'))
args: args:
chdir: /opt/upgrader/playbook/ chdir: /opt/upgrader/playbook/
- name: Upgrade Current Upgrade Signature - name: Upgrade Current Upgrade Signature
shell: cat /opt/upgrader/next-upgrade-signature > /opt/upgrader/current-upgrade-signature shell: cat /opt/upgrader/next-upgrade-signature > /opt/upgrader/current-upgrade-signature
when: 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'))
- shell: echo {{ ansible_date_time.epoch }} > /opt/upgrader/last-upgrade
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" minute="0" hour="*/3" job='ansible-playbook upgrader-run.yml --with-vars "upgrader-playbook={{ upgrader_playbook }}" -i hosts >> /opt/upgrader/latest_upgrade.log' cron: name="Launch Upgrader" minute="0" hour="*/3" job='ansible-playbook upgrader-run.yml --with-vars "upgrader-playbook={{ upgrader_playbook }}" -i hosts >> /opt/upgrader/latest_upgrade.log'
---
upgrade_after: 1434474611
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
hosts: 127.0.0.1 hosts: 127.0.0.1
connection: local connection: local
vars_files:
- settings/upgrader.yml
roles: roles:
- upgrader - upgrader
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
vars_files: vars_files:
- settings/vifib.yml - settings/vifib.yml
- settings/upgrader.yml
vars_prompt: vars_prompt:
- name: "computer_name" - name: "computer_name"
......
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