[CODE] caddy, cronmail: only run, if update needed

This commit is contained in:
Jannik Beyerstedt 2019-11-30 18:37:34 +01:00
parent 2d8903efeb
commit c0d2381824
4 changed files with 61 additions and 41 deletions

View file

@ -3,6 +3,8 @@
borgbackup_ssh_id: "/home/{{ ansible_user_id }}/.ssh/id_ed25519" borgbackup_ssh_id: "/home/{{ ansible_user_id }}/.ssh/id_ed25519"
caddy_cachedir: "/home/{{ ansible_user_id }}/.ansbl-caddy-cache"
telegraf_interval: "300s" telegraf_interval: "300s"
telegraf_docker_file: "telegraf-docker.conf" telegraf_docker_file: "telegraf-docker.conf"
telegraf_snmp_file: "telegraf-SNMP.conf" telegraf_snmp_file: "telegraf-SNMP.conf"

View file

@ -6,48 +6,63 @@
shell: lsb_release -is shell: lsb_release -is
register: lsb_id register: lsb_id
- name: caddyserver - Stop caddy - name: caddyserver - Create cache directory
become: yes
service:
name: caddy
state: stopped
ignore_errors: yes
- name: caddyserver - Make temp download directory
file: file:
path: /tmp/caddy path: "{{ caddy_cachedir }}"
state: directory state: directory
- name: caddyserver - Download caddy webserver (amd64) - name: caddyserver - Get all caddy releases
get_url: get_url:
url: "https://caddyserver.com/download/linux/amd64?plugins=http.ratelimit&license=personal" url: https://api.github.com/repos/caddyserver/caddy/git/refs/tags
dest: /tmp/caddy/caddy.tar.gz dest: "{{ caddy_cachedir }}/releases.txt"
when: lsb_id.stdout != "Raspbian" force: yes
- name: caddyserver - Download caddy webserver (raspberry pi) register: caddy_releases_cache
get_url:
url: "https://caddyserver.com/download/linux/arm7?plugins=http.ratelimit&license=personal"
dest: /tmp/caddy/caddy.tar.gz
when: lsb_id.stdout == "Raspbian"
- name: caddyserver - Extract caddy - name: caddyserver - Install or update
shell: "cd /tmp/caddy && tar -xvf caddy.tar.gz" block:
- name: caddyserver - Copy caddy to a PATH location - name: caddyserver - Make temp download directory
become: yes file:
shell: "cp /tmp/caddy/caddy /usr/local/bin" path: "{{ caddy_cachedir }}/tmp"
- name: caddyserver - Clean up download files state: directory
become: yes
file: - name: caddyserver - Download caddy webserver (amd64)
path: /tmp/caddy get_url:
state: absent url: "https://caddyserver.com/download/linux/amd64?plugins=http.ratelimit&license=personal"
- name: caddyserver - Install caddy APT dependencies dest: "{{ caddy_cachedir }}/tmp/caddy.tar.gz"
become: yes when: lsb_id.stdout != "Raspbian"
apt: - name: caddyserver - Download caddy webserver (raspberry pi)
name: libcap2-bin get_url:
state: present url: "https://caddyserver.com/download/linux/arm7?plugins=http.ratelimit&license=personal"
- name: caddyserver - Give caddy port binding capabilities dest: "{{ caddy_cachedir }}/tmp/caddy.tar.gz"
become: yes when: lsb_id.stdout == "Raspbian"
shell: "setcap cap_net_bind_service=+ep /usr/local/bin/caddy"
# capabilities: - name: caddyserver - Stop caddy
# path: "{{ caddy_bin }}" become: yes
# capability: cap_net_bind_service+ep service:
# state: present name: caddy
state: stopped
ignore_errors: yes
- name: caddyserver - Extract caddy
shell: "cd {{ caddy_cachedir }}/tmp && tar -xvf caddy.tar.gz"
- name: caddyserver - Copy caddy to a PATH location
become: yes
shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
- name: caddyserver - Clean up download files
become: yes
file:
path: "{{ caddy_cachedir }}/tmp"
state: absent
- name: caddyserver - Install caddy APT dependencies
become: yes
apt:
name: libcap2-bin
state: present
- name: caddyserver - Give caddy port binding capabilities
become: yes
shell: "setcap cap_net_bind_service=+ep /usr/local/bin/caddy"
# capabilities:
# path: "{{ caddy_bin }}"
# capability: cap_net_bind_service+ep
# state: present
when: caddy_releases_cache.changed

View file

@ -21,14 +21,17 @@
copy: copy:
src: "{{ role_path }}/files/exim4.conf.template" src: "{{ role_path }}/files/exim4.conf.template"
dest: /etc/exim4/exim4.conf.template dest: /etc/exim4/exim4.conf.template
register: cronmails_conftmp_update
- name: cronmails - Copy exim4 config file - name: cronmails - Copy exim4 config file
become: yes become: yes
template: template:
src: "{{ role_path }}/templates/update-exim4.conf.conf" src: "{{ role_path }}/templates/update-exim4.conf.conf"
dest: /etc/exim4/update-exim4.conf.conf dest: /etc/exim4/update-exim4.conf.conf
register: cronmails_conffile_update
- name: cronmails - Run update-exim4.conf - name: cronmails - Run update-exim4.conf
become: yes become: yes
shell: "update-exim4.conf" shell: "update-exim4.conf"
when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed
- name: cronmails - Enable and start exim4 - name: cronmails - Enable and start exim4
become: yes become: yes
service: service:

View file

@ -11,7 +11,7 @@
apt_key: apt_key:
url: https://repos.influxdata.com/influxdb.key url: https://repos.influxdata.com/influxdb.key
state: present state: present
- name: telegraf - Add Telegraf repo - name: telegraf - Add telegraf repo
become: yes become: yes
apt_repository: apt_repository:
repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable" repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable"