diff --git a/README.md b/README.md index db01bbfdcb09f3f2ebbca238e9b1142e708cd796..59f203342a723714a8ce874d53d06e25a8e9441f 100644 --- a/README.md +++ b/README.md @@ -26,22 +26,15 @@ ansible-playbook -u root discourse_upgrade.yml -i "${SERVERNAME}," -e "hostname= ## Docker Upgrade -Every 3 months there is a new version of `docker-ce` released, the steps to upgrade (this could potentially be written as a Ansible Playbook: +At least every 3 months there is a new version of `docker-ce` released, see the +[release notes](https://docs.docker.com/release-notes/docker-ce/), to upgrade +Docker CE use this playbook: ```bash -sudo -i -su - discourse -cd /var/discourse -./launcher app stop -exit -apt-get update -apt-get upgrade -service docker status # check the uptime and that it is running -su - discourse -cd /var/discourse -./launcher app start +export SERVERNAME="community.coops.tech" +ansible-playbook -u root docker_upgrade.yml -i "${SERVERNAME}," -e "hostname=${SERVERNAME}" ``` - + ## Discourse Install Ansible Playbooks to install diff --git a/discourse_upgrade.yml b/discourse_upgrade.yml index 3b58d6e462c0b6613be8f49e115e5d0261020db0..6d2f28081b2c1a76f623c24e6712d4e94e190860 100644 --- a/discourse_upgrade.yml +++ b/discourse_upgrade.yml @@ -1,5 +1,5 @@ --- -- name: Install Discourse +- name: Upgrade Discourse hosts: "{{ hostname }}" roles: diff --git a/docker_upgrade.yml b/docker_upgrade.yml new file mode 100644 index 0000000000000000000000000000000000000000..a354472df89ce17bb0d6f7e0f35c8332b4d13e24 --- /dev/null +++ b/docker_upgrade.yml @@ -0,0 +1,6 @@ +--- +- name: Upgrade Docker CE + hosts: "{{ hostname }}" + + roles: + - docker-upgrade diff --git a/roles/docker-upgrade/tasks/main.yml b/roles/docker-upgrade/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..39f351053d40ff7aff27ea27640d4a2ce7b3a5c1 --- /dev/null +++ b/roles/docker-upgrade/tasks/main.yml @@ -0,0 +1,64 @@ +--- +- name: Stop the Discourse container + command: bash launcher stop app + args: + chdir: "/var/discourse" + become: yes + become_user: discourse + +- name: Update apt package list + apt: + update_cache: yes + +- name: Check if the Webarchitects logchange script is installed + command: which logchange + register: logchange + +- block: + + - name: Get a list of the updates + shell: "apt-show-versions -b -u | xargs" + register: apt_updates + + - name: Record the updates in the /root/Changelog + command: 'logchange "{{ apt_updates.stdout }} : Updated"' + when: apt_updates.stdout != "" + + when: logchange.stdout != "" + +- name: Check if the Munin apt state file exists + stat: + path: "/var/lib/munin-node/plugin-state/nobody/plugin-apt.state" + register: munin_apt_state + +- block: + + - name: Delete the Munin apt state file + file: + dest: "/var/lib/munin-node/plugin-state/nobody/plugin-apt.state" + state: absent + + - name: Update the Munin apt state file + command: munin-run apt_all + + when: munin_apt_state.stat.exists == True + +- name: Update all packages + apt: + upgrade: dist + autoclean: yes + +- name: Restart Docker CE + service: + name: docker + state: restarted + +- name: Start the Discourse container + command: bash launcher start app + args: + chdir: "/var/discourse" + become: yes + become_user: discourse + + +