remove fqdn
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Torma Kristóf 2023-08-30 23:13:59 +02:00
parent 85fb26bf52
commit 52f7e7e153
19 changed files with 96 additions and 96 deletions

View File

@ -1,18 +1,18 @@
# TODO: Make backup user part of AD # TODO: Make backup user part of AD
--- ---
- name: "Add backup user" - name: "Add backup user"
ansible.builtin.user: user:
name: backup name: backup
comment: Backup user comment: Backup user
shell: /bin/bash shell: /bin/bash
- name: Create .ssh directory of backup user - name: Create .ssh directory of backup user
ansible.builtin.file: file:
path: /home/backup/.ssh path: /home/backup/.ssh
state: directory state: directory
- name: Copy authorized_keys - name: Copy authorized_keys
ansible.builtin.copy: copy:
src: authorized_keys src: authorized_keys
dest: /home/backup/.ssh/authorized_keys dest: /home/backup/.ssh/authorized_keys
mode: 0600 mode: 0600
@ -20,7 +20,7 @@
group: backup group: backup
- name: Copy ssh config - name: Copy ssh config
ansible.builtin.copy: copy:
src: ssh_config src: ssh_config
dest: /home/backup/.ssh/config dest: /home/backup/.ssh/config
mode: 0600 mode: 0600

View File

@ -1,6 +1,6 @@
--- ---
- name: "Generate backupscript" - name: "Generate backupscript"
ansible.builtin.template: template:
src: backupscript.sh src: backupscript.sh
dest: /etc/cron.weekly/backupscript dest: /etc/cron.weekly/backupscript
owner: root owner: root
@ -8,12 +8,12 @@
mode: '0700' mode: '0700'
- name: Create .ssh directory of root user - name: Create .ssh directory of root user
ansible.builtin.file: file:
path: /root/.ssh path: /root/.ssh
state: directory state: directory
- name: Copy ssh config - name: Copy ssh config
ansible.builtin.copy: copy:
src: ssh_config src: ssh_config
dest: /root/.ssh/config dest: /root/.ssh/config
mode: 0600 mode: 0600

View File

@ -1,26 +1,26 @@
--- ---
- name: "Use custom Ubuntu mirror" - name: "Use custom Ubuntu mirror"
ansible.builtin.replace: replace:
path: /etc/apt/sources.list path: /etc/apt/sources.list
regexp: 'http://hu.archive.ubuntu.com' regexp: 'http://hu.archive.ubuntu.com'
replace: 'https://mirror.niif.hu' replace: 'https://mirror.niif.hu'
backup: yes backup: yes
- name: "Remove Ubuntu bloatware" - name: "Remove Ubuntu bloatware"
ansible.builtin.apt: apt:
state: absent state: absent
name: ubutu-server name: ubutu-server
autoremove: yes autoremove: yes
- name: "Update machine" - name: "Update machine"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
upgrade: "yes" upgrade: "yes"
autoclean: yes autoclean: yes
autoremove: yes autoremove: yes
- name: "Install my favourite applications" - name: "Install my favourite applications"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:

View File

@ -1,6 +1,6 @@
--- ---
- name: clean motd - name: clean motd
ansible.builtin.file: file:
state: touch state: touch
owner: tormakris@intra.tormakris.dev owner: tormakris@intra.tormakris.dev
group: domain users@intra.tormakris.dev group: domain users@intra.tormakris.dev

View File

@ -1,12 +1,12 @@
--- ---
- name: disable cloudinit - name: disable cloudinit
ansible.builtin.copy: copy:
content: "" content: ""
dest: /etc/cloud/cloud-init.disabled dest: /etc/cloud/cloud-init.disabled
force: no force: no
- name: disable network autoconfig - name: disable network autoconfig
ansible.builtin.copy: copy:
content: "network: {config: disabled}" content: "network: {config: disabled}"
dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg dest: /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg
force: no force: no

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install node exporter" - name: "Install node exporter"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -14,7 +14,7 @@
src: 192.168.69.0/24 src: 192.168.69.0/24
- name: Enable and restart exporter daemon - name: Enable and restart exporter daemon
ansible.builtin.service: service:
name: prometheus-node-exporter name: prometheus-node-exporter
state: restarted state: restarted
enabled: yes enabled: yes

View File

@ -1,13 +1,13 @@
--- ---
- name: Remove snapd from Ubuntu - name: Remove snapd from Ubuntu
ansible.builtin.apt: apt:
name: snapd name: snapd
state: absent state: absent
purge: yes purge: yes
when: ansible_distribution == "Ubuntu" when: ansible_distribution == "Ubuntu"
- name: Remove snapd-related directories - name: Remove snapd-related directories
ansible.builtin.file: file:
path: "{{ item }}" path: "{{ item }}"
state: absent state: absent
with_items: with_items:

View File

@ -1,24 +1,24 @@
--- ---
- name: Disable root authentication - name: Disable root authentication
ansible.builtin.replace: replace:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
regexp: '#PermitRootLogin prohibit-password' regexp: '#PermitRootLogin prohibit-password'
replace: 'PermitRootLogin no' replace: 'PermitRootLogin no'
- name: Disable X11 forwarding - name: Disable X11 forwarding
ansible.builtin.replace: replace:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
regexp: 'X11Forwarding yes' regexp: 'X11Forwarding yes'
replace: 'X11Forwarding no' replace: 'X11Forwarding no'
- name: Explicitly only listen on ipv4 - name: Explicitly only listen on ipv4
ansible.builtin.replace: replace:
path: /etc/ssh/sshd_config path: /etc/ssh/sshd_config
regexp: '#AddressFamily any' regexp: '#AddressFamily any'
replace: 'AddressFamily inet' replace: 'AddressFamily inet'
- name: "Restart sshd" - name: "Restart sshd"
ansible.builtin.service: service:
name: sshd name: sshd
state: restarted state: restarted
... ...

View File

@ -1,18 +1,18 @@
--- ---
- name: Setup timesync config - name: Setup timesync config
ansible.builtin.template: template:
src: timesyncd.conf.template src: timesyncd.conf.template
dest: /etc/systemd/timesyncd.conf dest: /etc/systemd/timesyncd.conf
notify: run Timedatectl notify: run Timedatectl
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: set Timezone - name: set Timezone
ansible.builtin.timezone: name={{ timedatectl_timezone }} timezone: name={{ timedatectl_timezone }}
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
- name: Reastart timesyncd to apply changes - name: Reastart timesyncd to apply changes
when: ansible_service_mgr == "systemd" when: ansible_service_mgr == "systemd"
ansible.builtin.systemd: systemd:
state: restarted state: restarted
daemon_reload: yes daemon_reload: yes
name: systemd-timesyncd name: systemd-timesyncd

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install ufw via apt" - name: "Install ufw via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:

View File

@ -1,13 +1,13 @@
--- ---
- name: Create .ssh directory of ansible user - name: Create .ssh directory of ansible user
ansible.builtin.file: file:
path: /home/ansible@intra.tormakris.dev/.ssh path: /home/ansible@intra.tormakris.dev/.ssh
state: directory state: directory
owner: ansible@intra.tormakris.dev owner: ansible@intra.tormakris.dev
group: domain users@intra.tormakris.dev group: domain users@intra.tormakris.dev
- name: Copy authorized_keys - name: Copy authorized_keys
ansible.builtin.copy: copy:
src: authorized_keys src: authorized_keys
dest: /home/ansible@intra.tormakris.dev/.ssh/authorized_keys dest: /home/ansible@intra.tormakris.dev/.ssh/authorized_keys
mode: 0600 mode: 0600
@ -15,7 +15,7 @@
group: domain users@intra.tormakris.dev group: domain users@intra.tormakris.dev
- name: Check if group is present in sudoers - name: Check if group is present in sudoers
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/sudoers path: /etc/sudoers
regexp: "^%linuxadmins" regexp: "^%linuxadmins"
@ -24,7 +24,7 @@
register: checksudoers register: checksudoers
- name: Define group in sudoers - name: Define group in sudoers
ansible.builtin.lineinfile: lineinfile:
state: present state: present
path: /etc/sudoers path: /etc/sudoers
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL" line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install Docker via apt" - name: "Install Docker via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -8,7 +8,7 @@
- docker-compose - docker-compose
- name: Disable userland proxy - name: Disable userland proxy
ansible.builtin.copy: copy:
src: daemon.json src: daemon.json
dest: /etc/docker/daemon.json dest: /etc/docker/daemon.json
mode: 644 mode: 644
@ -16,13 +16,13 @@
group: backup group: backup
- name: Enable and restart Docker daemon - name: Enable and restart Docker daemon
ansible.builtin.service: service:
name: docker name: docker
state: restarted state: restarted
enabled: yes enabled: yes
- name: "Add service user to docker group" - name: "Add service user to docker group"
ansible.builtin.user: user:
name: service-user@intra.tormakris.dev name: service-user@intra.tormakris.dev
groups: docker groups: docker
append: yes append: yes

View File

@ -1,31 +1,31 @@
--- ---
- name: "Install Postfix via apt" - name: "Install Postfix via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
- postfix - postfix
- name: Install Postfix forwarder config - name: Install Postfix forwarder config
ansible.builtin.template: template:
src: templates/main.cf src: templates/main.cf
dest: /etc/postfix/main.cf dest: /etc/postfix/main.cf
- name: Restart Postfix - name: Restart Postfix
ansible.builtin.service: service:
name: postfix name: postfix
state: restarted state: restarted
enabled: yes enabled: yes
- name: "Install postfix exporter" - name: "Install postfix exporter"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
- prometheus-postfix-exporter - prometheus-postfix-exporter
- name: Copy postfix exporter config - name: Copy postfix exporter config
ansible.builtin.copy: copy:
src: prometheus-postfix-exporter src: prometheus-postfix-exporter
dest: /etc/default/prometheus-postfix-exporter dest: /etc/default/prometheus-postfix-exporter
owner: root owner: root
@ -33,13 +33,13 @@
mode: '0644' mode: '0644'
- name: Add the prometheus user to postdrop group - name: Add the prometheus user to postdrop group
ansible.builtin.user: user:
name: prometheus name: prometheus
groups: postdrop groups: postdrop
append: yes append: yes
- name: Enable and restart exporter daemon - name: Enable and restart exporter daemon
ansible.builtin.service: service:
name: prometheus-postfix-exporter name: prometheus-postfix-exporter
state: restarted state: restarted
enabled: yes enabled: yes

View File

@ -1,16 +1,16 @@
--- ---
- name: "remove cloudinit config" - name: "remove cloudinit config"
ansible.builtin.file: file:
path: /etc/netplan/50-cloud-init.yaml path: /etc/netplan/50-cloud-init.yaml
state: absent state: absent
- name: "remove installer config" - name: "remove installer config"
ansible.builtin.file: file:
path: /etc/netplan/00-installer-config.yaml path: /etc/netplan/00-installer-config.yaml
state: absent state: absent
- name: "install static config" - name: "install static config"
ansible.builtin.template: template:
src: templates/netplan.yaml src: templates/netplan.yaml
dest: /etc/netplan/00-static.yaml dest: /etc/netplan/00-static.yaml
notify: netplanapply notify: netplanapply

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install openvpn-server via apt" - name: "Install openvpn-server via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -15,13 +15,13 @@
reload: yes reload: yes
- name: Enable and restart openvpn daemon - name: Enable and restart openvpn daemon
ansible.builtin.service: service:
name: openvpn-server@stargate name: openvpn-server@stargate
state: restarted state: restarted
enabled: yes enabled: yes
- name: Check if AllowUsers is defined - name: Check if AllowUsers is defined
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/ufw/before.rules path: /etc/ufw/before.rules
regexp: "^# START OPENVPN" regexp: "^# START OPENVPN"
@ -30,7 +30,7 @@
register: checkufwrules register: checkufwrules
- name: Insert openvpn iptables rules - name: Insert openvpn iptables rules
ansible.builtin.blockinfile: blockinfile:
path: /etc/ufw/before.rules path: /etc/ufw/before.rules
block: | block: |
# START OPENVPN RULES # START OPENVPN RULES

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install realmd and dependencies" - name: "Install realmd and dependencies"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -16,7 +16,7 @@
- packagekit - packagekit
- name: Check if computer is joined to domain - name: Check if computer is joined to domain
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/sssd/sssd.conf path: /etc/sssd/sssd.conf
line: "^ad_access_filter" line: "^ad_access_filter"
@ -25,22 +25,22 @@
register: checkjoined register: checkjoined
- name: "Get join password from local environment variable" - name: "Get join password from local environment variable"
ansible.builtin.set_fact: set_fact:
join_passw: "{{ lookup('env', 'JOIN_PASSW') }}" join_passw: "{{ lookup('env', 'JOIN_PASSW') }}"
delegate_to: localhost delegate_to: localhost
when: checkjoined.found == 0 when: checkjoined.found == 0
- name: Join to AD with realmd - name: Join to AD with realmd
ansible.builtin.shell: shell:
cmd: echo {{ join_passw }} | realm join -v -U tormakris_admin intra.tormakris.dev cmd: echo {{ join_passw }} | realm join -v -U tormakris_admin intra.tormakris.dev
when: checkjoined.found == 0 when: checkjoined.found == 0
- name: Enable pam homedir create on first logon - name: Enable pam homedir create on first logon
ansible.builtin.command: command:
cmd: pam-auth-update --enable mkhomedir cmd: pam-auth-update --enable mkhomedir
- name: Check if ad_gpo_access_control is disabled - name: Check if ad_gpo_access_control is disabled
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/sssd/sssd.conf path: /etc/sssd/sssd.conf
regexp: "^ad_gpo_access_control" regexp: "^ad_gpo_access_control"
@ -49,14 +49,14 @@
register: checkadgpoac register: checkadgpoac
- name: Set ad_gpo_access_control to disabled - name: Set ad_gpo_access_control to disabled
ansible.builtin.lineinfile: lineinfile:
state: present state: present
path: /etc/sssd/sssd.conf path: /etc/sssd/sssd.conf
line: "ad_gpo_access_control = disabled" line: "ad_gpo_access_control = disabled"
when: checkadgpoac.found == 0 when: checkadgpoac.found == 0
- name: Check if ad_access_filter is set - name: Check if ad_access_filter is set
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/sssd/sssd.conf path: /etc/sssd/sssd.conf
regexp: "^ad_access_filter" regexp: "^ad_access_filter"
@ -65,19 +65,19 @@
register: checkadaf register: checkadaf
- name: Set ad_gpo_access_control to disabled - name: Set ad_gpo_access_control to disabled
ansible.builtin.lineinfile: lineinfile:
state: present state: present
path: /etc/sssd/sssd.conf path: /etc/sssd/sssd.conf
line: "ad_access_filter = memberOf=CN=LinuxUsers,OU=Service Groups,DC=intra,DC=tormakris,DC=dev" line: "ad_access_filter = memberOf=CN=LinuxUsers,OU=Service Groups,DC=intra,DC=tormakris,DC=dev"
when: checkadaf.found == 0 when: checkadaf.found == 0
- name: "Restart sssd" - name: "Restart sssd"
ansible.builtin.service: service:
name: sssd name: sssd
state: restarted state: restarted
- name: Check if group is presend in sudoers - name: Check if group is presend in sudoers
ansible.builtin.lineinfile: lineinfile:
state: absent state: absent
path: /etc/sudoers path: /etc/sudoers
regexp: "^%linuxadmins" regexp: "^%linuxadmins"
@ -86,7 +86,7 @@
register: checksudoers register: checksudoers
- name: Define group in sudoers - name: Define group in sudoers
ansible.builtin.lineinfile: lineinfile:
state: present state: present
path: /etc/sudoers path: /etc/sudoers
line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL" line: "%linuxadmins@intra.tormakris.dev ALL=(ALL) NOPASSWD: ALL"

View File

@ -1,22 +1,22 @@
--- ---
- name: "Install Postfix via apt" - name: "Install Postfix via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
- postfix - postfix
- name: Install Postfix mail gateway config - name: Install Postfix mail gateway config
ansible.builtin.template: template:
src: templates/main.cf src: templates/main.cf
dest: /etc/postfix/main.cf dest: /etc/postfix/main.cf
- name: Build /etc/mailname - name: Build /etc/mailname
ansible.builtin.shell: shell:
cmd: "hostname --fqdn > /etc/mailname" cmd: "hostname --fqdn > /etc/mailname"
- name: Restart Postfix - name: Restart Postfix
ansible.builtin.service: service:
name: postfix name: postfix
state: restarted state: restarted
enabled: yes enabled: yes
@ -28,14 +28,14 @@
src: 192.168.69.0/24 src: 192.168.69.0/24
- name: "Install postfix exporter" - name: "Install postfix exporter"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
- prometheus-postfix-exporter - prometheus-postfix-exporter
- name: Copy exporter config - name: Copy exporter config
ansible.builtin.copy: copy:
src: prometheus-postfix-exporter src: prometheus-postfix-exporter
dest: /etc/default/prometheus-postfix-exporter dest: /etc/default/prometheus-postfix-exporter
owner: root owner: root
@ -43,13 +43,13 @@
mode: '0644' mode: '0644'
- name: Add the prometheus user to postdrop group - name: Add the prometheus user to postdrop group
ansible.builtin.user: user:
name: prometheus name: prometheus
groups: postdrop groups: postdrop
append: yes append: yes
- name: Enable and restart exporter daemon - name: Enable and restart exporter daemon
ansible.builtin.service: service:
name: prometheus-postfix-exporter name: prometheus-postfix-exporter
state: restarted state: restarted
enabled: yes enabled: yes

View File

@ -1,6 +1,6 @@
--- ---
- name: "Install nginx via apt" - name: "Install nginx via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -19,7 +19,7 @@
port: https port: https
- name: Copy default nginx config - name: Copy default nginx config
ansible.builtin.copy: copy:
src: nginx.conf src: nginx.conf
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
owner: root owner: root
@ -27,28 +27,28 @@
mode: '0644' mode: '0644'
- name: Enable and restart nginx daemon - name: Enable and restart nginx daemon
ansible.builtin.service: service:
name: nginx name: nginx
state: restarted state: restarted
enabled: yes enabled: yes
- name: Generate certificate for all proxied domains - name: Generate certificate for all proxied domains
ansible.builtin.command: command:
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}} cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
with_items: "{{ proxy }}" with_items: "{{ proxy }}"
- name: Generate certificate for all static sites - name: Generate certificate for all static sites
ansible.builtin.command: command:
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}} cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
with_items: "{{ static }}" with_items: "{{ static }}"
- name: Generate certificate for all redirect sites - name: Generate certificate for all redirect sites
ansible.builtin.command: command:
cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}} cmd: certbot certonly --non-interactive --agree-tos -m tormakristof@tormakristof.eu --nginx -d {{item.domain}}
with_items: "{{ redirect }}" with_items: "{{ redirect }}"
- name: "Generate certbot script" - name: "Generate certbot script"
ansible.builtin.template: template:
src: certbot.sh src: certbot.sh
dest: /etc/cron.weekly/certbot dest: /etc/cron.weekly/certbot
owner: root owner: root
@ -56,7 +56,7 @@
mode: '0700' mode: '0700'
- name: "Generate nginx configuration" - name: "Generate nginx configuration"
ansible.builtin.template: template:
src: nginx.conf src: nginx.conf
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
owner: root owner: root
@ -64,41 +64,41 @@
mode: '0644' mode: '0644'
- name: Validate nginx configuration - name: Validate nginx configuration
ansible.builtin.command: command:
cmd: nginx -t cmd: nginx -t
- name: Reload nginx after configuration change - name: Reload nginx after configuration change
ansible.builtin.service: service:
name: nginx name: nginx
state: reloaded state: reloaded
- name: "Remove any existing static file directories" - name: "Remove any existing static file directories"
ansible.builtin.file: file:
path: "{{ item.directory }}" path: "{{ item.directory }}"
state: absent state: absent
with_items: "{{ static }}" with_items: "{{ static }}"
- name: "Checkout static websites from git" - name: "Checkout static websites from git"
ansible.builtin.git: git:
repo: "{{ item.repo }}" repo: "{{ item.repo }}"
dest: "{{ item.directory }}" dest: "{{ item.directory }}"
with_items: "{{ static }}" with_items: "{{ static }}"
- name: "Remove .git directory from static websites" - name: "Remove .git directory from static websites"
ansible.builtin.file: file:
path: "{{ item.directory }}/.git" path: "{{ item.directory }}/.git"
state: absent state: absent
with_items: "{{ static }}" with_items: "{{ static }}"
- name: "Install nginx exporter" - name: "Install nginx exporter"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
- prometheus-nginx-exporter - prometheus-nginx-exporter
- name: Copy nginx exporter config - name: Copy nginx exporter config
ansible.builtin.copy: copy:
src: prometheus-nginx-exporter src: prometheus-nginx-exporter
dest: /etc/default/prometheus-nginx-exporter dest: /etc/default/prometheus-nginx-exporter
owner: root owner: root
@ -106,7 +106,7 @@
mode: '0644' mode: '0644'
- name: Enable and restart exporter daemon - name: Enable and restart exporter daemon
ansible.builtin.service: service:
name: prometheus-nginx-exporter name: prometheus-nginx-exporter
state: restarted state: restarted
enabled: yes enabled: yes

View File

@ -7,7 +7,7 @@
with_items: "{{ allowedranges }}" with_items: "{{ allowedranges }}"
- name: "Install Nginx via apt" - name: "Install Nginx via apt"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -16,7 +16,7 @@
- python3-certbot-dns-cloudflare - python3-certbot-dns-cloudflare
- name: Copy default nginx config - name: Copy default nginx config
ansible.builtin.copy: copy:
src: nginx.conf src: nginx.conf
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
owner: root owner: root
@ -24,18 +24,18 @@
mode: '0644' mode: '0644'
- name: Enable and restart nginx daemon - name: Enable and restart nginx daemon
ansible.builtin.service: service:
name: nginx name: nginx
state: restarted state: restarted
enabled: yes enabled: yes
- name: "Get Cloudflare token from local environment variable" - name: "Get Cloudflare token from local environment variable"
ansible.builtin.set_fact: set_fact:
cloudflare_token: "{{ lookup('env', 'CLOUDFLARE_TOKEN') }}" cloudflare_token: "{{ lookup('env', 'CLOUDFLARE_TOKEN') }}"
delegate_to: localhost delegate_to: localhost
- name: "Render Cloudflare Certbot plugin configuration" - name: "Render Cloudflare Certbot plugin configuration"
ansible.builtin.template: template:
src: cf-creds.ini src: cf-creds.ini
dest: /root/cf-creds.ini dest: /root/cf-creds.ini
owner: root owner: root
@ -43,12 +43,12 @@
mode: 0600 mode: 0600
- name: Generate certificate for all server instances - name: Generate certificate for all server instances
ansible.builtin.shell: shell:
cmd: certbot certonly --non-interactive --agree-tos -m iam@tormakristof.eu --dns-cloudflare --dns-cloudflare-credentials /root/cf-creds.ini -d {{item.domain}} cmd: certbot certonly --non-interactive --agree-tos -m iam@tormakristof.eu --dns-cloudflare --dns-cloudflare-credentials /root/cf-creds.ini -d {{item.domain}}
with_items: "{{ webserver }}" with_items: "{{ webserver }}"
- name: "Generate certbot script" - name: "Generate certbot script"
ansible.builtin.template: template:
src: certbot.sh src: certbot.sh
dest: /etc/cron.weekly/certbot dest: /etc/cron.weekly/certbot
owner: root owner: root
@ -56,7 +56,7 @@
mode: '0700' mode: '0700'
- name: "Generate nginx configuration" - name: "Generate nginx configuration"
ansible.builtin.template: template:
src: nginx.conf src: nginx.conf
dest: /etc/nginx/nginx.conf dest: /etc/nginx/nginx.conf
owner: root owner: root
@ -64,12 +64,12 @@
mode: '0644' mode: '0644'
- name: Reload nginx daemon - name: Reload nginx daemon
ansible.builtin.service: service:
name: nginx name: nginx
state: reloaded state: reloaded
- name: "Install nginx exporter" - name: "Install nginx exporter"
ansible.builtin.apt: apt:
update_cache: yes update_cache: yes
state: present state: present
name: name:
@ -83,7 +83,7 @@
src: 192.168.69.0/24 src: 192.168.69.0/24
- name: Copy nginx exporter config - name: Copy nginx exporter config
ansible.builtin.copy: copy:
src: prometheus-nginx-exporter src: prometheus-nginx-exporter
dest: /etc/default/prometheus-nginx-exporter dest: /etc/default/prometheus-nginx-exporter
owner: root owner: root
@ -91,7 +91,7 @@
mode: '0644' mode: '0644'
- name: Enable and restart exporter daemon - name: Enable and restart exporter daemon
ansible.builtin.service: service:
name: prometheus-nginx-exporter name: prometheus-nginx-exporter
state: restarted state: restarted
enabled: yes enabled: yes