Commit 00bbd6cd authored by Alain Takoudjou's avatar Alain Takoudjou

playbook: upgrader for imt vm-bootstrap

parent fcae174d
......@@ -8,10 +8,6 @@
get_url: url=http://10.0.2.100/ipv4 dest=/etc/opt/ipv4 mode=666
ignore_errors: True
- name: Download cluster.hash
get_url: url=http://10.0.2.100/cluster.hash dest=/tmp/cluster.hash mode=666
ignore_errors: True
- name: stat /etc/opt/hostname
stat: path=/etc/opt/hostname
register: hostname_file
......@@ -20,8 +16,8 @@
stat: path=/etc/opt/ipv4
register: ipv4_file
- name: stat /tmp/cluster.hash
stat: path=/tmp/cluster.hash
- name: stat cluster.hash
stat: path=/etc/opt/cluster.hash
register: cluster_hash
- name: replace /etc/hostname
......
......@@ -23,8 +23,39 @@
when: netconfig_file.stat.exists == True
ignore_errors: True
- name: Download cluster.hash
get_url: url=http://10.0.2.100/cluster.hash dest=/etc/opt/cluster.hash mode=644
ignore_errors: True
- name: stat cluster.hash
stat: path=/etc/opt/cluster.hash
register: cluster_hash
- name: get upgrade file if exists
shell: wget --no-check-certificate "{{ lookup('file', '/etc/opt/cluster.hash') }}/data" -O /etc/opt/upgrade.after
when: cluster_hash.stat.exists == True
ignore_errors: True
- name: stat file upgrade.after
stat: path=/etc/opt/upgrade.after
register: upgrade_set
- name: check if the plabook should be upgraded
shell: cat /etc/opt/upgrade.after
register: upgrade_time
when: upgrade_set.stat.exists == True
- include: network.yml
- include: hostname.yml
- include: user.yml
- include: sudo.yml
- include: ssh.yml
- stat: path=/opt/upgrader/last-upgrade
register: last_upgrade
- shell: echo 1 > /opt/upgrader/last-upgrade
when: last_upgrade.stat.exists == False
- include: upgrader.yml upgrade_after={{ upgrade_time.stdout }}
when: upgrade_set.stat.exists == True and (upgrade_time.stdout|int > lookup('file', '/opt/upgrader/last-upgrade')|int)
---
- file: path=/opt/upgrader state=directory mode=0755
- stat: path=/opt/upgrader/current-upgrade-signature
register: current_upgrade_signature
- file: path=/opt/upgrader/ state=directory mode=0755
- shell: rm -rf /opt/upgrader/playbook/
- shell: rm -rf /opt/upgrader/archive.tar.gz
- shell: mkdir -p /opt/upgrader/playbook
- name: Download the latest playbook
shell: slapcache-download --destination=/opt/upgrader/archive.tar.gz
- name: Save new archive MD5
stat: path=/opt/upgrader/archive.tar.gz
register: archive
- name: Update playbook md5
shell: echo {{ archive.stat.md5 }} > /opt/upgrader/next-upgrade-signature
- name: Stat Current Upgrade Signature
file: path=/opt/upgrader/current-upgrade-signature state=touch mode="0666"
when: current_upgrade_signature.stat.exists == False
- name: Copy slapos.playbook
shell: tar -xzvf /opt/upgrader/archive.tar.gz
when: (upgrade_after|int > lookup('file', '/opt/upgrader/last-upgrade')|int ) and (lookup('file', '/opt/upgrader/next-upgrade-signature') != lookup('file', '/opt/upgrader/current-upgrade-signature'))
args:
chdir: /opt/slapos.playbook
- name: Upgrade Current Upgrade Signature
shell: echo /opt/upgrader/next-upgrade-signature > /opt/upgrader/current-upgrade-signature && echo {{ ansible_date_time.epoch }} > /opt/upgrader/last-upgrade
when: (upgrade_after|int > lookup('file', '/opt/upgrader/last-upgrade')|int )
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