Commit 50245b45 authored by Chris Croome's avatar Chris Croome
Browse files

Work in progress

parent 1ee5c6ce
......@@ -253,124 +253,147 @@
group: mailcow
recurse: yes
- name: Get updates/changes
- name: Checking remote code for updates
command: git fetch origin master
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_fetch_origin_master
- debug:
msg: "The results of `git fetch origin master`: {{ git_fetch_origin_master.stdout }}"
- name: Add all changed files to local clone
command: git add -A
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_add
- debug:
msg: "The results of `git add -A`: {{ git_add.stdout }}"
- name: Get the date and time
command: date
register: git_commit_date
- name: Commit changes
command: git commit -m "Local config at {{ git_commit_date.stdout }}"
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_commit
- debug:
msg: "The results of `git commit -m`: {{ git_commit.stdout }}"
- name: Merge changes, prefere mailcow repository
command: git merge -Xtheirs -Xpatience
- name: Checking for diffs
shell: "git diff origin/master --quiet 2>/dev/null"
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_merge
register: git_diff_origin_master
- debug:
msg: "The results of `git merge -Xtheirs -Xpatience`: {{ git_merge.stdout }}"
- name: Postfix files chowned to root:root
file:
path: /var/mailcow/data/conf/postfix
state: directory
owner: root
group: root
recurse: yes
msg: "The results of `git diff origin/master --quiet`: {{ git_diff_origin_master.stdout }}"
# https://github.com/mailcow/mailcow-dockerized/pull/203#issuecomment-299823762
- name: Run docker-compose down
command: docker-compose down
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
- block:
- name: Run docker-compose pull
command: docker-compose pull
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
- name: Run docker-compose up -d --remove-orphans
command: docker-compose up -d --remove-orphans
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
- name: Check for unused images
shell: "docker images -f 'dangling=true' -q | xargs"
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
register: docker_dangling_images
- block:
- name: Clean-up dangling (unused) images
shell: "docker rmi -f {{ docker_dangling_images.stdout }}"
# https://github.com/mailcow/mailcow-dockerized/pull/203#issuecomment-299823762
- name: Run docker-compose down
command: docker-compose down
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
- name: Add all changed files to local clone
command: git add -u
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_add
- debug:
msg: "The results of `git add -u`: {{ git_add.stdout }}"
- name: Get the date and time
command: date
register: git_commit_date
- name: Commit changes
command: git commit -am "Local config at {{ git_commit_date.stdout }}"
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_commit
- debug:
msg: "The results of `git commit -am`: {{ git_commit.stdout }}"
when: docker_dangling_images.stdout != ""
- name: Check for unused volumes
command: docker volume ls -qf 'dangling=true'
become: yes
become_user: mailcow
register: docker_dangling_volumes
- block:
- name: Clean-up dangling (unused) volumes
shell: "docker volume rm {{ docker_dangling_volumes.stdout }}"
- name: Running git fetch origin master
command: git fetch origin master
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_fetch_origin_master
- debug:
msg: "The results of `git fetch origin master`: {{ git_fetch_origin_master.stdout }}"
- name: Merge changes, prefer mailcow repository
command: git merge -Xtheirs -Xpatience
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
register: git_merge
- debug:
msg: "The results of `git merge -Xtheirs -Xpatience`: {{ git_merge.stdout }}"
- name: Postfix files chowned to root:root
file:
path: /var/mailcow/data/conf/postfix
state: directory
owner: root
group: root
recurse: yes
- name: Run docker-compose pull
command: docker-compose pull
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
- name: Run docker-compose up -d --remove-orphans
command: docker-compose up -d --remove-orphans
args:
chdir: /var/mailcow
become: yes
become_user: mailcow
- name: Check for unused images
shell: "docker images -f 'dangling=true' -q | xargs"
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
when: docker_dangling_volumes.stdout != ""
register: docker_dangling_images
- block:
- name: Clean-up dangling (unused) images
shell: "docker rmi -f {{ docker_dangling_images.stdout }}"
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
when: docker_dangling_images.stdout != ""
- name: Check for unused volumes
command: docker volume ls -qf 'dangling=true'
become: yes
become_user: mailcow
register: docker_dangling_volumes
- block:
- name: Clean-up dangling (unused) volumes
shell: "docker volume rm {{ docker_dangling_volumes.stdout }}"
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
when: docker_dangling_volumes.stdout != ""
when: git_diff_origin_master.stdout != ""
when: mailcow_git_directory.stat.exists == True
- block:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment