Skip to content

Instantly share code, notes, and snippets.

@justanwar
Forked from goodc0re/update_zcoin_mns.yml
Last active December 20, 2019 10:35
Show Gist options
  • Save justanwar/864fa6f92d9be7d0d0d336a15f5f9bfa to your computer and use it in GitHub Desktop.
Save justanwar/864fa6f92d9be7d0d0d336a15f5f9bfa to your computer and use it in GitHub Desktop.
Ansible playbook to update a zcoin masternode on Ubuntu, update Ubuntu with apt and reboot if needed
# update_zcoin_mns.yml
---
- hosts: zcoin_masternodes
vars_files: vault.yml
become: yes
become_method: sudo
tasks:
- name: Download zcoin binary
become: no
get_url:
url: https://github.com/zcoinofficial/zcoin/releases/download/v0.13.8.9/zcoin-0.13.8.9-linux64.tar.gz
dest: /home/znode
mode: 0440
- name: Stop zcoind
become: no
command: ./zcoin-cli stop
args:
chdir: /home/znode/zcoin-0.13.8/bin
- name: Delete old binaries
become: yes
file:
path: /home/znode/zcoin-0.13.8
state: absent
- name: Unarchive zcoin binary
become: no
unarchive:
src: /home/znode/zcoin-0.13.8.9-linux64.tar.gz
dest: /home/znode/
remote_src: yes
- name: Delete downloaded archive
become: no
file:
path: /home/znode/zcoin-0.13.8.9-linux64.tar.gz
state: absent
- name: Delete znpayments.dat and zncache.dat and
become: no
file:
path: "{{ item }}"
state: absent
with_items:
- /home/znode/.zcoin/zncache.dat
- /home/znode/.zcoin/znpayments.dat
- name: Update all packages on a Debian/Ubuntu
apt:
update_cache: yes
upgrade: dist
- name: Check if a reboot is required
register: reboot_required_file
stat: path=/var/run/reboot-required get_md5=no
- name: Reboot box if kernel/libs updated and requested by the system
shell: sleep 10 && /sbin/shutdown -r now 'Rebooting box to update system libs/kernel as needed'
args:
removes: /var/run/reboot-required
async: 300
poll: 0
ignore_errors: true
when: reboot_required_file.stat.exists == true
- name: Wait for system to become reachable again
wait_for_connection:
delay: 60
timeout: 300
when: reboot_required_file.stat.exists == true
- name: Verify new update (optional)
command: uname -mrs
register: uname_result
when: reboot_required_file.stat.exists == true
- name: Display new kernel version
debug:
var: uname_result.stdout_lines
when: reboot_required_file.stat.exists == true
- name: Restart znode
become: no
command: ./zcoind -daemon
args:
chdir: /home/znode/zcoin-0.13.8/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment