Created
September 22, 2021 07:35
-
-
Save goodc0re/6ece2272b2c5b9fd93ca9791735839c8 to your computer and use it in GitHub Desktop.
Ansible playbook to update a dash masternode without dashman on Ubuntu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# update_dash_mns.yml | |
--- | |
- hosts: dash_masternodes | |
vars_files: vault.yml | |
become: yes | |
become_method: sudo | |
tasks: | |
- name: 'Ensure dashd job is no longer present. Removes any job that is prefixed by "#Ansible: dashd" from the crontab' | |
ansible.builtin.cron: | |
name: "dashd" | |
state: absent | |
- name: Download dash binary | |
become: no | |
get_url: | |
url: https://github.com/dashpay/dash/releases/download/v0.17.0.3/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz | |
dest: /tmp | |
mode: 0440 | |
- name: Stop dashd | |
become: no | |
command: ./dash-cli stop | |
args: | |
chdir: /home/dash/.dashcore | |
- name: Unarchive dash binary | |
become: no | |
unarchive: | |
src: /tmp/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz | |
dest: /tmp/ | |
remote_src: yes | |
- name: Copy dashd | |
ansible.builtin.copy: | |
src: /tmp/dashcore-0.17.0/bin/dashd | |
dest: /home/dash/.dashcore/ | |
owner: dash | |
group: dash | |
mode: u=rwx,g=rx,o=rx | |
- name: Copy dash-cli | |
ansible.builtin.copy: | |
src: /tmp/dashcore-0.17.0/bin/dash-cli | |
dest: /home/dash/.dashcore/ | |
owner: dash | |
group: dash | |
mode: u=rwx,g=rx,o=rx | |
- name: Delete downloaded archive | |
become: no | |
file: | |
path: /tmp/dashcore-0.17.0.3-x86_64-linux-gnu.tar.gz | |
state: absent | |
- 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 dashd | |
become: no | |
command: ~/.dashcore/dashd | |
args: | |
chdir: /home/dash/.dashcore/ | |
- name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null" | |
ansible.builtin.cron: | |
name: "dashd" | |
job: "pidof dashd || ~/.dashcore/dashd" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer to the ansible documentation at https://docs.ansible.com/ansible/latest/user_guide/index.html#getting-started
This playbook requires:
Command I use to run this playbook with ansible:
$ ansible-playbook -i hosts --ask-vault-pass update_dash_mns.yml -vv