Commit 7b0cac5e authored by Chris Croome's avatar Chris Croome
Browse files

Work in progress

parent 50245b45
......@@ -260,137 +260,125 @@
become: yes
become_user: mailcow
- name: Checking for diffs
shell: "git diff origin/master --quiet 2>/dev/null"
- name: Check the git status for files to commit
shell: git status | grep "nothing to commit"
args:
chdir: /var/mailcow
executable: /bin/bash
become: yes
become_user: mailcow
register: git_diff_origin_master
register: git_status
- debug:
msg: "The results of `git diff origin/master --quiet`: {{ git_diff_origin_master.stdout }}"
- block:
# 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: Add all changed files to local clone
command: git add -u
command: git add -A
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 }}"
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 -am`: {{ git_commit.stdout }}"
msg: "The results of `git commit -m`: {{ git_commit.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
when: git_status != ""
- 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
- 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
# 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
- 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 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: 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
- name: Check for unused images
shell: "docker images -f 'dangling=true' -q | xargs"
- 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
register: docker_dangling_images
- block:
when: docker_dangling_images.stdout != ""
- 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
- name: Check for unused volumes
command: docker volume ls -qf 'dangling=true'
become: yes
become_user: mailcow
register: docker_dangling_volumes
when: docker_dangling_images.stdout != ""
- block:
- name: Check for unused volumes
command: docker volume ls -qf 'dangling=true'
- 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
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: docker_dangling_volumes.stdout != ""
when: mailcow_git_directory.stat.exists == True
......
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