[TIDY] Update to ansible 4 module names

This commit is contained in:
Jannik Beyerstedt 2021-08-28 16:50:37 +02:00
parent 3c1939f431
commit a2fc598416
19 changed files with 89 additions and 89 deletions

View file

@ -86,46 +86,46 @@ The different tasks should be used on a case-by-case basis:
hosts: servers hosts: servers
tasks: tasks:
- name: Servers - Generic setup tasks - name: Servers - Generic setup tasks
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: setup tasks_from: setup
- name: Servers - Setup cronjob mails - name: Servers - Setup cronjob mails
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: cronmails tasks_from: cronmails
- name: Servers - Setup dyndns cronjob - name: Servers - Setup dyndns cronjob
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: dyndns tasks_from: dyndns
- name: Servers - Setup monitoring - name: Servers - Setup monitoring
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: telegraf tasks_from: telegraf
- name: Servers - Setup backups (if variables are set) - name: Servers - Setup backups (if variables are set)
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: borgbackup tasks_from: borgbackup
# Docker # Docker
- name: Servers - Install docker - name: Servers - Install docker
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: docker tasks_from: docker
- name: Servers - Add telegraf to docker group - name: Servers - Add telegraf to docker group
become: yes become: yes
user: ansible.builtin.user:
name: telegraf name: telegraf
groups: docker groups: docker
append: yes append: yes
# Caddy Webserver # Caddy Webserver
- name: Servers - Install and setup caddy - name: Servers - Install and setup caddy
import_role: ansible.builtin.import_role:
name: server name: server
tasks_from: caddyserver tasks_from: caddyserver
- name: Servers - Start caddy service - name: Servers - Start caddy service
become: yes become: yes
service: ansible.builtin.service:
name: caddy name: caddy
enabled: yes enabled: yes
state: started state: started
@ -133,7 +133,7 @@ The different tasks should be used on a case-by-case basis:
# UFW Firewall # UFW Firewall
- name: Servers - Install UFW - name: Servers - Install UFW
become: yes become: yes
apt: ansible.builtin.apt:
name: ufw name: ufw
state: present state: present
``` ```

View file

@ -3,25 +3,25 @@
- name: Restart sshd - name: Restart sshd
become: yes become: yes
service: ansible.builtin.service:
name: ssh name: ssh
state: restarted state: restarted
- name: Enable caddy - name: Enable caddy
become: yes become: yes
service: ansible.builtin.service:
name: caddy name: caddy
enabled: yes enabled: yes
- name: Restart caddy - name: Restart caddy
become: yes become: yes
service: ansible.builtin.service:
name: caddy name: caddy
state: restarted state: restarted
- name: Enable and restart caddy - name: Enable and restart caddy
become: yes become: yes
service: ansible.builtin.service:
name: caddy name: caddy
state: restarted state: restarted
enabled: yes enabled: yes

View file

@ -9,7 +9,7 @@
- name: borgbackup - Add debian repo key - name: borgbackup - Add debian repo key
become: yes become: yes
apt_key: ansible.builtin.apt_key:
keyserver: pgpkeys.mit.edu keyserver: pgpkeys.mit.edu
id: 8B48AD6246925553 id: 8B48AD6246925553
state: present state: present
@ -17,14 +17,14 @@
- ansible_distribution_release == 'stretch' - ansible_distribution_release == 'stretch'
- name: borgbackup - Add stretch-backports - name: borgbackup - Add stretch-backports
become: yes become: yes
apt_repository: ansible.builtin.apt_repository:
repo: deb http://ftp.debian.org/debian stretch-backports main repo: deb http://ftp.debian.org/debian stretch-backports main
state: present state: present
when: when:
- ansible_distribution_release == 'stretch' - ansible_distribution_release == 'stretch'
- name: borgbackup - Install borgbackup from stretch-backports - name: borgbackup - Install borgbackup from stretch-backports
become: yes become: yes
apt: ansible.builtin.apt:
name: borgbackup name: borgbackup
state: latest state: latest
default_release: stretch-backports default_release: stretch-backports

View file

@ -9,7 +9,7 @@
- name: borgbackup - Install borgbackup - name: borgbackup - Install borgbackup
become: yes become: yes
apt: ansible.builtin.apt:
name: borgbackup name: borgbackup
state: present state: present
when: when:

View file

@ -6,7 +6,7 @@
# - borgbackup_hostname # - borgbackup_hostname
- name: borgbackup - Install - name: borgbackup - Install
include_tasks: "{{ item }}" ansible.builtin.include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "borgbackup-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" - "borgbackup-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "borgbackup-{{ ansible_distribution }}.yml" - "borgbackup-{{ ansible_distribution }}.yml"
@ -20,7 +20,7 @@
# copy backup script and enable cronjob # copy backup script and enable cronjob
- name: borgbackup - Copy Borgbackup script - name: borgbackup - Copy Borgbackup script
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/borgbackup.sh" src: "{{ role_path }}/templates/borgbackup.sh"
dest: /usr/local/bin/borgbackup.sh dest: /usr/local/bin/borgbackup.sh
owner: "{{ ansible_user_id }}" owner: "{{ ansible_user_id }}"
@ -32,7 +32,7 @@
- borgbackup_hostname is defined - borgbackup_hostname is defined
- name: borgbackup - Run Borgbackup script at 1:00 daily - name: borgbackup - Run Borgbackup script at 1:00 daily
become: yes become: yes
cron: ansible.builtin.cron:
name: "Create Backup" name: "Create Backup"
minute: "0" minute: "0"
hour: "1" hour: "1"
@ -47,12 +47,12 @@
block: block:
- name: borgbackup - Remove Borgbackup script if no borgbackup config - name: borgbackup - Remove Borgbackup script if no borgbackup config
become: yes become: yes
file: ansible.builtin.file:
path: /usr/local/bin/borgbackup.sh path: /usr/local/bin/borgbackup.sh
state: absent state: absent
- name: borgbackup - Remove Cronjob if no borgbackup config - name: borgbackup - Remove Cronjob if no borgbackup config
become: yes become: yes
cron: ansible.builtin.cron:
name: "Create Backup" name: "Create Backup"
minute: "0" minute: "0"
hour: "1" hour: "1"

View file

@ -2,12 +2,12 @@
# Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules) # Server/Caddyserver-Install: Install/Update Caddy Webserver (with some modules)
- name: caddyserver - Create cache directory - name: caddyserver - Create cache directory
file: ansible.builtin.file:
path: "{{ caddy_cachedir }}" path: "{{ caddy_cachedir }}"
state: directory state: directory
- name: caddyserver - Get all caddy releases - name: caddyserver - Get all caddy releases
get_url: ansible.builtin.get_url:
url: https://api.github.com/repos/caddyserver/caddy/git/refs/tags url: https://api.github.com/repos/caddyserver/caddy/git/refs/tags
dest: "{{ caddy_cachedir }}/releases.txt" dest: "{{ caddy_cachedir }}/releases.txt"
force: yes force: yes
@ -16,13 +16,13 @@
- name: caddyserver - Install or update - name: caddyserver - Install or update
block: block:
- name: caddyserver - Make temp download directory - name: caddyserver - Make temp download directory
file: ansible.builtin.file:
path: "{{ caddy_cachedir }}/tmp" path: "{{ caddy_cachedir }}/tmp"
state: directory state: directory
- name: caddyserver - Download caddy webserver (amd64) - name: caddyserver - Download caddy webserver (amd64)
become: yes become: yes
get_url: ansible.builtin.get_url:
url: "https://caddyserver.com/api/download?os=linux&arch=amd64" url: "https://caddyserver.com/api/download?os=linux&arch=amd64"
dest: "{{ caddy_cachedir }}/tmp/caddy" dest: "{{ caddy_cachedir }}/tmp/caddy"
group: root group: root
@ -31,7 +31,7 @@
when: ansible_architecture == "x86_64" when: ansible_architecture == "x86_64"
- name: caddyserver - Download caddy webserver (armv7/ raspberry pi) - name: caddyserver - Download caddy webserver (armv7/ raspberry pi)
become: yes become: yes
get_url: ansible.builtin.get_url:
url: "https://caddyserver.com/api/download?os=linux&arch=arm&arm=7" url: "https://caddyserver.com/api/download?os=linux&arch=arm&arm=7"
dest: "{{ caddy_cachedir }}/tmp/caddy" dest: "{{ caddy_cachedir }}/tmp/caddy"
group: root group: root
@ -40,7 +40,7 @@
when: ansible_architecture == "armv7l" when: ansible_architecture == "armv7l"
- name: caddyserver - Download caddy webserver (arm64) - name: caddyserver - Download caddy webserver (arm64)
become: yes become: yes
get_url: ansible.builtin.get_url:
url: "https://caddyserver.com/api/download?os=linux&arch=arm64" url: "https://caddyserver.com/api/download?os=linux&arch=arm64"
dest: "{{ caddy_cachedir }}/tmp/caddy" dest: "{{ caddy_cachedir }}/tmp/caddy"
group: root group: root
@ -50,17 +50,17 @@
- name: caddyserver - Stop caddy - name: caddyserver - Stop caddy
become: yes become: yes
service: ansible.builtin.service:
name: caddy name: caddy
state: stopped state: stopped
ignore_errors: yes ignore_errors: yes
- name: caddyserver - Copy caddy to a PATH location - name: caddyserver - Copy caddy to a PATH location
become: yes become: yes
shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin" ansible.builtin.shell: "cp {{ caddy_cachedir }}/tmp/caddy /usr/local/bin"
- name: caddyserver - Clean up download files - name: caddyserver - Clean up download files
become: yes become: yes
file: ansible.builtin.file:
path: "{{ caddy_cachedir }}/tmp" path: "{{ caddy_cachedir }}/tmp"
state: absent state: absent
when: caddy_releases_cache.changed when: caddy_releases_cache.changed

View file

@ -3,7 +3,7 @@
- name: caddyserver - Add www-data system user - name: caddyserver - Add www-data system user
become: yes become: yes
user: ansible.builtin.user:
name: www-data name: www-data
create_home: no create_home: no
system: yes system: yes
@ -11,7 +11,7 @@
state: present state: present
- name: caddyserver - Add Caddy directories - name: caddyserver - Add Caddy directories
become: yes become: yes
file: ansible.builtin.file:
path: "{{ item }}" path: "{{ item }}"
state: directory state: directory
owner: www-data owner: www-data
@ -22,7 +22,7 @@
- /etc/caddy - /etc/caddy
- name: caddyserver - Add Caddy home directory - name: caddyserver - Add Caddy home directory
become: yes become: yes
file: ansible.builtin.file:
path: /var/www path: /var/www
state: directory state: directory
owner: www-data owner: www-data
@ -30,7 +30,7 @@
mode: 0555 mode: 0555
- name: caddyserver - Copy Caddy systemd service file - name: caddyserver - Copy Caddy systemd service file
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/caddy.service" src: "{{ role_path }}/templates/caddy.service"
dest: /etc/systemd/system/caddy.service dest: /etc/systemd/system/caddy.service
owner: root owner: root
@ -39,7 +39,7 @@
- name: caddyserver - Add standard user to www-data group - name: caddyserver - Add standard user to www-data group
become: yes become: yes
user: ansible.builtin.user:
name: "{{ ansible_user_id }}" name: "{{ ansible_user_id }}"
groups: www-data groups: www-data
append: yes append: yes

View file

@ -3,8 +3,8 @@
# ATTENTION: No Caddyfile is created yet and caddy is not enabled or started! # ATTENTION: No Caddyfile is created yet and caddy is not enabled or started!
- name: caddyserver - Install caddy server - name: caddyserver - Install caddy server
include_tasks: "caddy-install.yml" ansible.builtin.include_tasks: "caddy-install.yml"
- name: caddyserver - Setup caddy server - name: caddyserver - Setup caddy server
include_tasks: "caddy-setup.yml" ansible.builtin.include_tasks: "caddy-setup.yml"
when: caddy_email is defined when: caddy_email is defined

View file

@ -4,7 +4,7 @@
# Install exim # Install exim
- name: cronmails - Install exim4 as MTA - name: cronmails - Install exim4 as MTA
become: yes become: yes
yum: ansible.builtin.yum:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:
@ -14,29 +14,29 @@
# Configure exim # Configure exim
- name: cronmails - Create exim config folder - name: cronmails - Create exim config folder
become: yes become: yes
file: ansible.builtin.file:
path: /etc/exim path: /etc/exim
state: directory state: directory
# TODO: exim config works quite differently on CentOS compared to Debian!!! # TODO: exim config works quite differently on CentOS compared to Debian!!!
# # - name: cronmails - Copy exim config template # # - name: cronmails - Copy exim config template
# # become: yes # # become: yes
# # copy: # # ansible.builtin.copy:
# # src: "{{ role_path }}/files/exim4.conf.template" # # src: "{{ role_path }}/files/exim4.conf.template"
# # dest: /etc/exim/exim.conf.template # # dest: /etc/exim/exim.conf.template
# # register: cronmails_conftmp_update # # register: cronmails_conftmp_update
# # - name: cronmails - Copy exim config file # # - name: cronmails - Copy exim config file
# # become: yes # # become: yes
# # template: # # ansible.builtin.template:
# # src: "{{ role_path }}/templates/update-exim4.conf.conf" # # src: "{{ role_path }}/templates/update-exim4.conf.conf"
# # dest: /etc/exim/update-exim.conf.conf # # dest: /etc/exim/update-exim.conf.conf
# # register: cronmails_conffile_update # # register: cronmails_conffile_update
# # - name: cronmails - Run update-exim.conf # # - name: cronmails - Run update-exim.conf
# # become: yes # # become: yes
# # shell: "update-exim.conf" # # ansible.builtin.shell: "update-exim.conf"
# # when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed # # when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed
# - name: cronmails - Enable and start exim # - name: cronmails - Enable and start exim
# become: yes # become: yes
# service: # ansible.builtin.service:
# name: exim # name: exim
# state: started # state: started
# enabled: yes # enabled: yes

View file

@ -4,7 +4,7 @@
# Install exim # Install exim
- name: cronmails - Install exim4 as MTA - name: cronmails - Install exim4 as MTA
become: yes become: yes
apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:
@ -15,28 +15,28 @@
# Configure exim # Configure exim
- name: cronmails - Create exim4 config folder - name: cronmails - Create exim4 config folder
become: yes become: yes
file: ansible.builtin.file:
path: /etc/exim4 path: /etc/exim4
state: directory state: directory
- name: cronmails - Copy exim4 config template - name: cronmails - Copy exim4 config template
become: yes become: yes
copy: ansible.builtin.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 register: cronmails_conftmp_update
- name: cronmails - Copy exim4 config file - name: cronmails - Copy exim4 config file
become: yes become: yes
template: ansible.builtin.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 register: cronmails_conffile_update
- name: cronmails - Run update-exim4.conf - name: cronmails - Run update-exim4.conf
become: yes become: yes
shell: "update-exim4.conf" ansible.builtin.shell: "update-exim4.conf"
when: cronmails_conftmp_update.changed or cronmails_conffile_update.changed 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: ansible.builtin.service:
name: exim4 name: exim4
state: started state: started
enabled: yes enabled: yes

View file

@ -3,7 +3,7 @@
# Install and configure exim # Install and configure exim
- name: cronmails - Install exim4 - name: cronmails - Install exim4
include_tasks: "{{ item }}" ansible.builtin.include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" - "cronmails-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "cronmails-{{ ansible_distribution }}.yml" - "cronmails-{{ ansible_distribution }}.yml"
@ -13,13 +13,13 @@
# Set cronjob env variables/ settings # Set cronjob env variables/ settings
- name: cronmails - Crontab set path - name: cronmails - Crontab set path
become: yes become: yes
cron: ansible.builtin.cron:
name: PATH name: PATH
env: yes env: yes
value: /bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin value: /bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin
- name: cronmails - Crontab set mailto - name: cronmails - Crontab set mailto
become: yes become: yes
cron: ansible.builtin.cron:
name: MAILTO name: MAILTO
env: yes env: yes
value: "{{ cron_email }}" value: "{{ cron_email }}"

View file

@ -5,13 +5,13 @@
# Detect some more host facts # Detect some more host facts
- name: docker - Detect architecture - name: docker - Detect architecture
shell: dpkg --print-architecture ansible.builtin.shell: dpkg --print-architecture
register: dpkg_arch register: dpkg_arch
# Install docker CE # Install docker CE
- name: docker - Install docker CE APT dependencies - name: docker - Install docker CE APT dependencies
become: yes become: yes
apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:
@ -23,27 +23,27 @@
- software-properties-common - software-properties-common
- name: docker - Add docker CE repo key - name: docker - Add docker CE repo key
become: yes become: yes
apt_key: ansible.builtin.apt_key:
url: https://download.docker.com/linux/debian/gpg url: https://download.docker.com/linux/debian/gpg
state: present state: present
# IMPORTANT: raspbian needs deb [arch=armhf] https://download.docker.com/linux/raspbian ... # IMPORTANT: raspbian needs deb [arch=armhf] https://download.docker.com/linux/raspbian ...
- name: docker - Add docker CE repo (Debian) - name: docker - Add docker CE repo (Debian)
become: yes become: yes
apt_repository: ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable" repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/debian {{ ansible_distribution_release }} stable"
state: present state: present
when: ansible_facts['lsb']['id'] != "Raspbian" when: ansible_facts['lsb']['id'] != "Raspbian"
- name: docker - Add docker CE repo (Raspbian) - name: docker - Add docker CE repo (Raspbian)
become: yes become: yes
apt_repository: ansible.builtin.apt_repository:
repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable" repo: "deb [arch={{ dpkg_arch.stdout }}] https://download.docker.com/linux/raspbian {{ ansible_distribution_release }} stable"
state: present state: present
when: ansible_facts['lsb']['id'] == "Raspbian" when: ansible_facts['lsb']['id'] == "Raspbian"
- name: docker - Install docker CE - name: docker - Install docker CE
become: yes become: yes
apt: ansible.builtin.apt:
name: docker-ce name: docker-ce
state: latest state: latest
install_recommends: no install_recommends: no
@ -54,14 +54,14 @@
# docker only provides pre-compiled binaries for x86_64, but not for armhf/ arm64! # docker only provides pre-compiled binaries for x86_64, but not for armhf/ arm64!
# but ansible needs the python package anyway # but ansible needs the python package anyway
- name: docker-compose - Discover if ARM is used - name: docker-compose - Discover if ARM is used
set_fact: ansible.builtin.set_fact:
dockercompose_use_pip: true dockercompose_use_pip: true
when: ansible_architecture == "aarch64" or ansible_architecture == "armv7l" when: ansible_architecture == "aarch64" or ansible_architecture == "armv7l"
- name: docker-compose - Install x86_46 binary - name: docker-compose - Install x86_46 binary
block: block:
- name: docker-compose - Get version number of stable - name: docker-compose - Get version number of stable
shell: | ansible.builtin.shell: |
curl -s https://api.github.com/repos/docker/compose/releases/latest \ curl -s https://api.github.com/repos/docker/compose/releases/latest \
| grep tag_name \ | grep tag_name \
| cut -d '"' -f 4 | cut -d '"' -f 4
@ -70,13 +70,13 @@
register: latest_dc_version register: latest_dc_version
- name: docker-compose - Download and install - name: docker-compose - Download and install
become: yes become: yes
get_url: ansible.builtin.get_url:
url: "https://github.com/docker/compose/releases/download/{{ latest_dc_version.stdout }}/docker-compose-Linux-x86_64" url: "https://github.com/docker/compose/releases/download/{{ latest_dc_version.stdout }}/docker-compose-Linux-x86_64"
dest: /usr/local/bin/docker-compose dest: /usr/local/bin/docker-compose
force: yes # otherwise updates will not be downloaded force: yes # otherwise updates will not be downloaded
- name: docker-compose - Make docker-compose executable - name: docker-compose - Make docker-compose executable
become: yes become: yes
file: ansible.builtin.file:
path: /usr/local/bin/docker-compose path: /usr/local/bin/docker-compose
mode: 0755 mode: 0755
when: dockercompose_use_pip == false and ansible_architecture == "x86_64" when: dockercompose_use_pip == false and ansible_architecture == "x86_64"
@ -84,7 +84,7 @@
block: block:
- name: docker-compose - Install requirements - name: docker-compose - Install requirements
become: yes become: yes
apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:
@ -93,7 +93,7 @@
- python3-setuptools - python3-setuptools
- name: docker-compose - Install using pip3 - name: docker-compose - Install using pip3
become: yes become: yes
pip: ansible.builtin.pip:
name: docker-compose name: docker-compose
executable: pip3 executable: pip3
when: dockercompose_use_pip == true when: dockercompose_use_pip == true

View file

@ -4,7 +4,7 @@
# - dockercompose_use_pip: boolean to use pip instead of manual download (default: false) # - dockercompose_use_pip: boolean to use pip instead of manual download (default: false)
- name: docker - Install - name: docker - Install
include_tasks: "{{ item }}" ansible.builtin.include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "docker-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" - "docker-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "docker-{{ ansible_distribution }}.yml" - "docker-{{ ansible_distribution }}.yml"
@ -13,7 +13,7 @@
# Other setup tasks # Other setup tasks
- name: docker - Add standard user to docker group - name: docker - Add standard user to docker group
become: yes become: yes
user: ansible.builtin.user:
name: "{{ ansible_user_id }}" name: "{{ ansible_user_id }}"
groups: docker groups: docker
append: yes append: yes

View file

@ -3,13 +3,13 @@
- name: dyndns - Install needed tools - name: dyndns - Install needed tools
become: yes become: yes
package: ansible.builtin.package:
name: curl name: curl
state: present state: present
- name: dyndns - Copy dynDNS script - name: dyndns - Copy dynDNS script
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/ddns-hosts.sh" src: "{{ role_path }}/templates/ddns-hosts.sh"
dest: /usr/local/bin/ddns-hosts.sh dest: /usr/local/bin/ddns-hosts.sh
owner: "{{ ansible_user_id }}" owner: "{{ ansible_user_id }}"
@ -17,7 +17,7 @@
mode: 0775 mode: 0775
- name: "dyndns - Create cronjob for {{ ddns_zone }} dynDNS script" - name: "dyndns - Create cronjob for {{ ddns_zone }} dynDNS script"
become: yes become: yes
cron: ansible.builtin.cron:
name: "{{ ddns_zone }} dynDNS" name: "{{ ddns_zone }} dynDNS"
minute: "*/5" minute: "*/5"
hour: "*" hour: "*"

View file

@ -4,7 +4,7 @@
# Activate them on a case-by-case basis. # Activate them on a case-by-case basis.
- name: Basic setup - name: Basic setup
import_tasks: setup.yml ansible.builtin.import_tasks: setup.yml
- name: Setup cronjob mails - name: Setup cronjob mails
import_tasks: cronmails.yml ansible.builtin.import_tasks: cronmails.yml

View file

@ -4,7 +4,7 @@
# SSH # SSH
- name: setup - Copy sshd_config - name: setup - Copy sshd_config
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/sshd_config.j2" src: "{{ role_path }}/templates/sshd_config.j2"
dest: "/etc/ssh/sshd_config" dest: "/etc/ssh/sshd_config"
backup: yes backup: yes

View file

@ -3,7 +3,7 @@
- name: telegraf - Add telegraf repo - name: telegraf - Add telegraf repo
become: yes become: yes
yum_repository: ansible.builtin.yum_repository:
name: influxdb name: influxdb
description: InfluxDB Repository description: InfluxDB Repository
baseurl: https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable baseurl: https://repos.influxdata.com/rhel/\$releasever/\$basearch/stable
@ -12,7 +12,7 @@
gpgkey: https://repos.influxdata.com/influxdb.key gpgkey: https://repos.influxdata.com/influxdb.key
- name: telegraf - Install telegraf - name: telegraf - Install telegraf
become: yes become: yes
yum: ansible.builtin.yum:
name: telegraf name: telegraf
state: latest state: latest
update_cache: yes update_cache: yes

View file

@ -3,22 +3,22 @@
- name: telegraf - Install apt-transport-https - name: telegraf - Install apt-transport-https
become: yes become: yes
apt: ansible.builtin.apt:
name: apt-transport-https name: apt-transport-https
state: present state: present
- name: telegraf - Add telegraf repo key - name: telegraf - Add telegraf repo key
become: yes become: yes
apt_key: ansible.builtin.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: ansible.builtin.apt_repository:
repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable" repo: "deb https://repos.influxdata.com/debian {{ ansible_distribution_release }} stable"
state: present state: present
- name: telegraf - Install telegraf - name: telegraf - Install telegraf
become: yes become: yes
apt: ansible.builtin.apt:
name: telegraf name: telegraf
state: latest state: latest
update_cache: yes update_cache: yes
@ -27,7 +27,7 @@
# Install SNMP utilities for telegraf monitoring # Install SNMP utilities for telegraf monitoring
- name: telegraf - Install SNMP utilities - name: telegraf - Install SNMP utilities
become: yes become: yes
apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:

View file

@ -3,7 +3,7 @@
# Install # Install
- name: telegraf - Install telegraf - name: telegraf - Install telegraf
include_tasks: "{{ item }}" ansible.builtin.include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "telegraf-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml" - "telegraf-{{ ansible_distribution }}.{{ ansible_distribution_release }}.yml"
- "telegraf-{{ ansible_distribution }}.yml" - "telegraf-{{ ansible_distribution }}.yml"
@ -14,19 +14,19 @@
become: yes become: yes
block: block:
- name: SNMP - Download and install Ubiquiti MIB - name: SNMP - Download and install Ubiquiti MIB
copy: ansible.builtin.copy:
src: "{{ role_path }}/files/UBNT-MIB.txt" src: "{{ role_path }}/files/UBNT-MIB.txt"
dest: /usr/share/snmp/mibs/UBNT-MIB dest: /usr/share/snmp/mibs/UBNT-MIB
- name: SNMP - Download and install Ubiquiti MIB - name: SNMP - Download and install Ubiquiti MIB
copy: ansible.builtin.copy:
src: "{{ role_path }}/files/UBNT-AirMAX-MIB.txt" src: "{{ role_path }}/files/UBNT-AirMAX-MIB.txt"
dest: /usr/share/snmp/mibs/UBNT-AirMAX-MIB dest: /usr/share/snmp/mibs/UBNT-AirMAX-MIB
- name: SNMP - Download and install UniFi MIB - name: SNMP - Download and install UniFi MIB
copy: ansible.builtin.copy:
src: "{{ role_path }}/files/UBNT-UniFi-MIB.txt" src: "{{ role_path }}/files/UBNT-UniFi-MIB.txt"
dest: /usr/share/snmp/mibs/UBNT-UniFi-MIB dest: /usr/share/snmp/mibs/UBNT-UniFi-MIB
- name: SNMP - Setup snmp.conf - name: SNMP - Setup snmp.conf
lineinfile: ansible.builtin.lineinfile:
name: /etc/snmp/snmp.conf name: /etc/snmp/snmp.conf
line: mibs +ALL line: mibs +ALL
create: yes create: yes
@ -35,21 +35,21 @@
# Configure # Configure
- name: telegraf - Copy telegraf config (Linux) - name: telegraf - Copy telegraf config (Linux)
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/telegraf.conf.j2" src: "{{ role_path }}/templates/telegraf.conf.j2"
dest: /etc/telegraf/telegraf.conf dest: /etc/telegraf/telegraf.conf
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "FreeBSD" when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) != "FreeBSD"
- name: telegraf - Copy telegraf config (FreeBSD) - name: telegraf - Copy telegraf config (FreeBSD)
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/telegraf.conf.j2" src: "{{ role_path }}/templates/telegraf.conf.j2"
dest: /usr/local/etc/telegraf.conf dest: /usr/local/etc/telegraf.conf
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "FreeBSD" when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "FreeBSD"
- name: telegraf - Enable and restart telegraf - name: telegraf - Enable and restart telegraf
become: yes become: yes
service: ansible.builtin.service:
name: telegraf name: telegraf
state: restarted state: restarted
enabled: yes enabled: yes