[TIDY] Update to ansible 4 module names

This commit is contained in:
Jannik Beyerstedt 2021-08-28 16:48:58 +02:00
parent be3d627bdb
commit 5553f66031
5 changed files with 18 additions and 18 deletions

View file

@ -64,7 +64,7 @@ Playbook:
hosts: tinc hosts: tinc
tasks: tasks:
- name: Tinc - Distribute hostfiles - name: Tinc - Distribute hostfiles
import_role: ansible.builtin.import_role:
name: tinc name: tinc
tasks_from: distribute tasks_from: distribute
``` ```

View file

@ -2,12 +2,12 @@
# Tinc VPN Hostfile Distribution # Tinc VPN Hostfile Distribution
- name: Distribute - Set different base dir for macOS - name: Distribute - Set different base dir for macOS
set_fact: ansible.builtin.set_fact:
tinc_base_dir: /usr/local/etc/tinc tinc_base_dir: /usr/local/etc/tinc
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin" when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin"
- name: Distribute - Copy hostfiles to targets - name: Distribute - Copy hostfiles to targets
become: yes become: yes
copy: ansible.builtin.copy:
src: "{{ role_path }}/files/tmp/" src: "{{ role_path }}/files/tmp/"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/"

View file

@ -2,26 +2,26 @@
# Tinc VPN Setup and Configuration # Tinc VPN Setup and Configuration
- name: Main - Set different base dir for macOS - name: Main - Set different base dir for macOS
set_fact: ansible.builtin.set_fact:
tinc_base_dir: /usr/local/etc/tinc tinc_base_dir: /usr/local/etc/tinc
when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin" when: (override_os_family is defined) | ternary(override_os_family,ansible_os_family) == "Darwin"
- name: Main - Install tinc - name: Main - Install tinc
include_tasks: "{{ item }}" ansible.builtin.include_tasks: "{{ item }}"
with_first_found: with_first_found:
- "setup-{{ ansible_distribution }}.yml" - "setup-{{ ansible_distribution }}.yml"
- "setup-{{ (override_os_family is defined) | ternary(override_os_family,ansible_os_family) }}.yml" - "setup-{{ (override_os_family is defined) | ternary(override_os_family,ansible_os_family) }}.yml"
- name: Main - Create tinc directories - name: Main - Create tinc directories
become: yes become: yes
file: ansible.builtin.file:
path: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts" path: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts"
state: directory state: directory
mode: "0755" mode: "0755"
- name: Main - Create new host keypair - name: Main - Create new host keypair
become: yes become: yes
shell: | ansible.builtin.shell: |
export PATH=/usr/local/sbin:/usr/local/bin:$PATH export PATH=/usr/local/sbin:/usr/local/bin:$PATH
tincd -n {{ tinc_vpn_id }} -K4096 tincd -n {{ tinc_vpn_id }} -K4096
args: args:
@ -30,40 +30,40 @@
- name: Main - Create config - name: Main - Create config
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/tinc.conf.j2" src: "{{ role_path }}/templates/tinc.conf.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc.conf" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc.conf"
- name: Main - Fetch public key - name: Main - Fetch public key
become: yes become: yes
fetch: ansible.builtin.fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/rsa_key.pub" src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/rsa_key.pub"
dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_hostname | replace('-', '_') }}.pub" dest: "{{ role_path }}/templates/tmp/rsa_key-{{ ansible_hostname | replace('-', '_') }}.pub"
flat: yes flat: yes
- name: Main - Create own hostfile - name: Main - Create own hostfile
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/hostfile.j2" src: "{{ role_path }}/templates/hostfile.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
- name: Main - Create tinc-up script - name: Main - Create tinc-up script
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/tinc-up.j2" src: "{{ role_path }}/templates/tinc-up.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc-up" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc-up"
mode: "0755" mode: "0755"
- name: Main - Create tinc-down script - name: Main - Create tinc-down script
become: yes become: yes
template: ansible.builtin.template:
src: "{{ role_path }}/templates/tinc-down.j2" src: "{{ role_path }}/templates/tinc-down.j2"
dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc-down" dest: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/tinc-down"
mode: "0755" mode: "0755"
- name: Main - Fetch all hostfiles - name: Main - Fetch all hostfiles
become: yes become: yes
fetch: ansible.builtin.fetch:
src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}" src: "{{ tinc_base_dir }}/{{ tinc_vpn_id }}/hosts/{{ ansible_hostname | replace('-', '_') }}"
dest: "{{ role_path }}/files/tmp/{{ ansible_hostname | replace('-', '_') }}" dest: "{{ role_path }}/files/tmp/{{ ansible_hostname | replace('-', '_') }}"
flat: yes flat: yes
@ -72,17 +72,17 @@
become: yes become: yes
block: block:
- name: "Main - Enable {{ tinc_vpn_id }} in tinc config" - name: "Main - Enable {{ tinc_vpn_id }} in tinc config"
lineinfile: ansible.builtin.lineinfile:
name: "{{ tinc_base_dir }}/nets.boot" name: "{{ tinc_base_dir }}/nets.boot"
line: "{{ tinc_vpn_id }}" line: "{{ tinc_vpn_id }}"
create: yes create: yes
- name: "Main - Enable and restart tinc service" - name: "Main - Enable and restart tinc service"
systemd: ansible.builtin.systemd:
name: tinc name: tinc
state: restarted state: restarted
enabled: yes enabled: yes
- name: "Main - Enable and restart tinc@{{ tinc_vpn_id }} service" - name: "Main - Enable and restart tinc@{{ tinc_vpn_id }} service"
systemd: ansible.builtin.systemd:
name: "tinc@{{ tinc_vpn_id }}" name: "tinc@{{ tinc_vpn_id }}"
state: restarted state: restarted
enabled: yes enabled: yes

View file

@ -2,7 +2,7 @@
# Tinc/Setup: Install tinc application - macOS Version # Tinc/Setup: Install tinc application - macOS Version
- name: Setup - Install - name: Setup - Install
package: ansible.builtin.package:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars:

View file

@ -3,7 +3,7 @@
- name: Setup - Install - name: Setup - Install
become: yes become: yes
apt: ansible.builtin.apt:
name: "{{ packages }}" name: "{{ packages }}"
state: present state: present
vars: vars: