Playbook to upgrade containers

Moved Ansible host requirements to 'ansible' role and created role
'upgrade' and playbook to help with upgrading containers.
This commit is contained in:
Kris Lamoureux 2019-12-14 23:12:59 -05:00
parent efb29a2c37
commit f1917f6a40
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
5 changed files with 63 additions and 20 deletions

1
.gitignore vendored
View File

@ -2,4 +2,5 @@
/*.yml
/*.yaml
!moxie.yml
!upgrade-moxie.yml
/environments/

View File

@ -15,27 +15,8 @@
- name: Install Moxie Server
hosts: moxietest
become: true
# Install host requirements for playbooks
pre_tasks:
- name: 'Install Ansible dependency: python-apt'
shell: 'apt-get update && apt-get install python-apt -y'
args:
creates: /usr/lib/python2.7/dist-packages/apt
warn: false
- name: 'Install Ansible dependency: aptitude'
apt:
name: 'aptitude'
state: present
force_apt_get: true
- name: 'Install Ansible dependency: python-docker'
apt:
name: python-docker
roles:
- ansible
- docker
- traefik
- wordpress

View File

@ -0,0 +1,16 @@
- name: 'Install Ansible dependency: python-apt'
shell: 'apt-get update && apt-get install python-apt -y'
args:
creates: /usr/lib/python2.7/dist-packages/apt
warn: false
- name: 'Install Ansible dependency: aptitude'
apt:
name: 'aptitude'
state: present
force_apt_get: true
- name: 'Install Ansible dependency: python-docker'
apt:
name: python-docker
state: present

View File

@ -0,0 +1,38 @@
- name: Download new Traefik container
docker_image:
name: "traefik:{{ traefik_version }}"
source: pull
register: new_traefik
- name: Download new WordPress container
docker_image:
name: "wordpress:{{ wordpress_version }}"
source: pull
register: new_wordpress
- name: Download new MariaDB container
docker_image:
name: "mariadb:{{ mariadb_version }}"
source: pull
register: new_mariadb
- name: Stop and remove old Traefik container
docker_container:
name: "{{ traefik_name }}"
image: "traefik:{{ traefik_version }}"
state: absent
when: new_traefik.changed
- name: Stop and remove old WordPress container
docker_container:
name: "{{ wordpress_name }}"
image: "wordpress:{{ wordpress_version }}"
state: absent
when: new_wordpress.changed
- name: Stop and remove old MariaDB container
docker_container:
name: "{{ mariadb_name }}"
image: "mariadb:{{ mariadb_version }}"
state: absent
when: new_mariadb.changed

7
upgrade-moxie.yml Normal file
View File

@ -0,0 +1,7 @@
- name: Upgrade Moxie Server
hosts: moxietest
become: true
roles:
- upgrade
- traefik
- wordpress