2024-04-09 11:42:03 +00:00
|
|
|
---
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Python Library"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: ansible
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Create Symbolic Links"
|
2024-04-09 11:42:03 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
src: /opt/ansible/bin/{{ binary }}
|
2024-04-29 13:40:51 +00:00
|
|
|
dest: /usr/bin/{{ binary }}
|
2024-04-09 11:42:03 +00:00
|
|
|
state: link
|
|
|
|
vars:
|
|
|
|
binaries:
|
|
|
|
- ansible
|
|
|
|
- ansible-community
|
|
|
|
- ansible-config
|
|
|
|
- ansible-connection
|
|
|
|
- ansible-console
|
|
|
|
- ansible-doc
|
|
|
|
- ansible-galaxy
|
|
|
|
- ansible-inventory
|
|
|
|
- ansible-playbook
|
|
|
|
- ansible-pull
|
|
|
|
- ansible-test
|
|
|
|
- ansible-vault
|
|
|
|
loop: "{{ binaries }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ binary }}"
|
|
|
|
loop_var: "binary"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Dependencies / Python Library : hvac"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: hvac
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Dependencies / Python Library : netaddr"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: netaddr
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Dependencies / Python Library : jmespath"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: jmespath
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Ansible - Dependencies / Python Library : pexpect"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: pexpect
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- ansible
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Podman"
|
2024-04-09 11:42:03 +00:00
|
|
|
apt:
|
|
|
|
name: podman
|
|
|
|
state: latest
|
|
|
|
tags:
|
|
|
|
- podman
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer : Podman : Configure - Subordinate Ids : Users : root"
|
2024-05-02 15:14:57 +00:00
|
|
|
lineinfile:
|
|
|
|
path: /etc/subuid
|
|
|
|
regexp: "^root"
|
|
|
|
line: "root:100000:65536"
|
|
|
|
|
|
|
|
- name: "Installer : Podman : Configure - Subordinate Ids : Groups : root"
|
|
|
|
lineinfile:
|
|
|
|
path: /etc/subgid
|
|
|
|
regexp: "^root"
|
|
|
|
line: "root:100000:65536"
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Certbot - Python Library"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: certbot
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
|
|
|
tags:
|
|
|
|
- certbot
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Certbot - Create Symbolic Links"
|
2024-04-09 11:42:03 +00:00
|
|
|
ansible.builtin.file:
|
|
|
|
src: /opt/ansible/bin/{{ binary }}
|
2024-04-29 13:40:51 +00:00
|
|
|
dest: /usr/bin/{{ binary }}
|
2024-04-09 11:42:03 +00:00
|
|
|
state: link
|
|
|
|
vars:
|
|
|
|
binaries:
|
|
|
|
- certbot
|
|
|
|
loop: "{{ binaries }}"
|
|
|
|
loop_control:
|
|
|
|
label: "{{ binary }}"
|
|
|
|
loop_var: "binary"
|
|
|
|
tags:
|
|
|
|
- certbot
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Certbot - Auth Hook"
|
2024-04-18 14:50:57 +00:00
|
|
|
copy:
|
|
|
|
src: "../files/certbot/nginx.sh"
|
|
|
|
dest: "/etc/letsencrypt/renewal-hooks/pre/nginx.sh"
|
|
|
|
mode: '700'
|
|
|
|
force: true
|
|
|
|
tags:
|
|
|
|
- certbot
|
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Certbot - Create Certificates"
|
2024-04-18 14:50:57 +00:00
|
|
|
command: "certbot certonly --cert-name {{ cert.name }} --manual --preferred-challenges http-01 --email {{ cert.email }} --server https://acme-v02.api.letsencrypt.org/directory --agree-tos -n --manual-auth-hook /etc/letsencrypt/renewal-hooks/pre/nginx.sh --debug-challenges --preferred-chain='ISRG Root X1' --key-type rsa -d {{ cert.domains | join(' -d ') }}"
|
2024-04-18 14:24:24 +00:00
|
|
|
register: task
|
|
|
|
changed_when: task.stdout.find("Certificate not yet due for renewal; no action taken.") == -1
|
|
|
|
vars:
|
|
|
|
cert:
|
|
|
|
name: mpp
|
|
|
|
email: matias.martikainen@metropolia.fi
|
|
|
|
domains:
|
|
|
|
- "{{ ansible_facts.fqdn }}"
|
|
|
|
tags:
|
|
|
|
- certbot
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - MariaDB - Dependencies / Python Library : pymysql"
|
2024-04-09 11:42:03 +00:00
|
|
|
pip:
|
|
|
|
name: pymysql
|
|
|
|
state: latest
|
|
|
|
extra_args: --upgrade
|
|
|
|
virtualenv: /opt/ansible
|
|
|
|
virtualenv_command: "python3 -m venv"
|
2024-04-18 14:27:35 +00:00
|
|
|
tags:
|
|
|
|
- mariadb
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - MariaDB - Dependencies / Package : mariadb-client"
|
2024-04-09 11:42:03 +00:00
|
|
|
apt:
|
|
|
|
name: "mariadb-client"
|
|
|
|
state: latest
|
|
|
|
when:
|
|
|
|
- ansible_facts.distribution == "Debian" or ansible_facts.distribution == "Ubuntu" or ansible_facts.distribution == "Linux Mint"
|
2024-04-18 14:27:35 +00:00
|
|
|
tags:
|
|
|
|
- mariadb
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Schedule - Maintenance"
|
2024-04-09 11:42:03 +00:00
|
|
|
cron:
|
|
|
|
name: Maintenance
|
|
|
|
hour: "*/3"
|
|
|
|
minute: "0"
|
2024-05-02 15:23:40 +00:00
|
|
|
job: "/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa tasks.yml -t maintenance"
|
2024-04-18 14:27:35 +00:00
|
|
|
tags:
|
|
|
|
- cron
|
2024-04-09 11:42:03 +00:00
|
|
|
|
2024-05-03 12:27:44 +00:00
|
|
|
- name: "Installer - Schedule - Deployer"
|
2024-04-18 14:26:16 +00:00
|
|
|
cron:
|
|
|
|
name: Deployer
|
|
|
|
minute: "*/5"
|
2024-05-02 15:23:40 +00:00
|
|
|
job: "/opt/ansible/bin/ansible-pull -U ssh://git@github.com/MatteZ02/mpp-infra --accept-host-key --private-key ~/.ssh/id_rsa tasks.yml -t deployer"
|
2024-04-18 14:27:35 +00:00
|
|
|
tags:
|
|
|
|
- cron
|