diff --git a/.gitignore b/.gitignore index 1bc9341..5f3f30d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /*.yml /*.yaml !moxie.yml +!upgrade-moxie.yml /environments/ diff --git a/moxie.yml b/moxie.yml index 7e19c3f..41e652a 100644 --- a/moxie.yml +++ b/moxie.yml @@ -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 diff --git a/roles/ansible/tasks/main.yml b/roles/ansible/tasks/main.yml new file mode 100644 index 0000000..5aa5408 --- /dev/null +++ b/roles/ansible/tasks/main.yml @@ -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 diff --git a/roles/upgrade/tasks/main.yml b/roles/upgrade/tasks/main.yml new file mode 100644 index 0000000..f563a3f --- /dev/null +++ b/roles/upgrade/tasks/main.yml @@ -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 diff --git a/upgrade-moxie.yml b/upgrade-moxie.yml new file mode 100644 index 0000000..51737ab --- /dev/null +++ b/upgrade-moxie.yml @@ -0,0 +1,7 @@ +- name: Upgrade Moxie Server + hosts: moxietest + become: true + roles: + - upgrade + - traefik + - wordpress