mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-07-02 07:48:32 +02:00
Compare commits
85 Commits
344bd02895
...
main
Author | SHA1 | Date | |
---|---|---|---|
3732db698e | |||
42fdd319a3 | |||
47e730ef60 | |||
ddee60ab9c | |||
41bd0fbe73 | |||
dac032de7c | |||
899d130325 | |||
8e7fb3bc42 | |||
46da0fa6e9 | |||
2f3f58c965 | |||
264f510541 | |||
b01bdb59f1 | |||
644d8b1a59 | |||
230c665365 | |||
6a0f33c73f | |||
026925081e | |||
5426f7ae3d | |||
d255ad37ad | |||
89030dec11 | |||
6df5f17cfe | |||
ff8ebb3940 | |||
6a720e2e89 | |||
02dc0134c4 | |||
e7fb37545f | |||
5927ad571e | |||
9871b8cb29 | |||
6de27cd975 | |||
d2c7c49d68 | |||
9e3ce2e113 | |||
bb248011ad | |||
4a7838cd19 | |||
9a21d1c273 | |||
2b4421d92d | |||
8c88139223 | |||
a2825f31c3 | |||
024a3bb61f | |||
9bc4c937de | |||
f339cb755a | |||
5ab8d6cf02 | |||
153c3a5d1a | |||
f18365f184 | |||
e6ab9ac621 | |||
c2ba911536 | |||
9be37d9ad5 | |||
80ddec608a | |||
24191afe3d | |||
4c1e374f23 | |||
eaa4ecd07a | |||
d4ee9dc3eb | |||
16414f9bc4 | |||
04eb197989 | |||
5957435c36 | |||
b3de421b3a | |||
977c9ca44e | |||
e15b4ec2a8 | |||
365a045d4d | |||
0c730c0b65 | |||
83f37fc18a | |||
378d2ee456 | |||
7632faae6e | |||
2285c420ec | |||
187c422759 | |||
b2b98ef238 | |||
5fd82279f1 | |||
9eb9fb6190 | |||
75a458dfb5 | |||
792961fe55 | |||
5ceb74a148 | |||
a42ef3a30b | |||
dbd2a549be | |||
14d455d84d | |||
62584425b4 | |||
482244589f | |||
3f601f92a0 | |||
5792932507 | |||
d92720f4d0 | |||
76aa74ff2f | |||
74def16ccd | |||
592d4a7db0 | |||
3808a8bb3f | |||
e2410e7e30 | |||
fbd878540e | |||
195e227c69 | |||
a6b4adb7d1 | |||
b671f8b37b |
9
.gitea/workflows/demo.yaml
Normal file
9
.gitea/workflows/demo.yaml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
name: Gitea Actions Demo
|
||||||
|
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Explore-Gitea-Actions:
|
||||||
|
runs-on: jaydee
|
||||||
|
steps:
|
||||||
|
- run: curl -X GET https://kestra.sectorq.eu/api/v1/executions/webhook/jaydee/ansible-all/f851511c32ca9450
|
44
all.yml
44
all.yml
@ -1,29 +1,67 @@
|
|||||||
---
|
|
||||||
- hosts: datacenter
|
- hosts: datacenter
|
||||||
|
name: Roles
|
||||||
|
gather_facts: false
|
||||||
roles:
|
roles:
|
||||||
|
- name: setup
|
||||||
|
role: setup
|
||||||
|
tags: setup
|
||||||
- name: common
|
- name: common
|
||||||
tags: common
|
tags: common
|
||||||
|
role: common
|
||||||
|
- name: hosts
|
||||||
|
role: hosts
|
||||||
|
tags: hosts
|
||||||
|
- name: ssh_config
|
||||||
|
role: ssh_config
|
||||||
|
tags: ssh_config
|
||||||
|
- name: sshd_config
|
||||||
|
role: sshd_config
|
||||||
|
tags: sshd_config
|
||||||
|
- name: ssh_keys
|
||||||
|
role: ssh_keys
|
||||||
|
tags: ssh_keys
|
||||||
- name: wake_on_lan
|
- name: wake_on_lan
|
||||||
|
role: wake_on_lan
|
||||||
tags: wake_on_lan
|
tags: wake_on_lan
|
||||||
- name: matter-server
|
- name: matter-server
|
||||||
|
role: matter-server
|
||||||
tags: matter-server
|
tags: matter-server
|
||||||
- name: docker
|
- name: docker
|
||||||
|
role: docker
|
||||||
tags: docker
|
tags: docker
|
||||||
- name: timeshift
|
- name: timeshift
|
||||||
|
role: timeshift
|
||||||
tags: timeshift
|
tags: timeshift
|
||||||
- name: monitoring
|
- name: monitoring
|
||||||
|
role: monitoring
|
||||||
tags: monitoring
|
tags: monitoring
|
||||||
- name: zabbix-agent
|
- name: zabbix-agent
|
||||||
|
role: zabbix-agent
|
||||||
tags: zabbix-agent
|
tags: zabbix-agent
|
||||||
- name: autofs_client
|
- name: autofs_client
|
||||||
|
role: autofs_client
|
||||||
tags: autofs_client
|
tags: autofs_client
|
||||||
- name: ldap_client
|
- name: ldap_client
|
||||||
|
role: ldap_client
|
||||||
tags: ldap_client
|
tags: ldap_client
|
||||||
- name: ssh_banner
|
- name: ssh_banner
|
||||||
|
role: ssh_banner
|
||||||
tags: ssh_banner
|
tags: ssh_banner
|
||||||
- name: omv_backup
|
- name: omv_backup
|
||||||
|
role: omv_backup
|
||||||
tags: omv_backup
|
tags: omv_backup
|
||||||
- name: wazuh-agent
|
- name: wazuh-agent
|
||||||
|
role: wazuh-agent
|
||||||
tags: wazuh-agent
|
tags: wazuh-agent
|
||||||
- role: mqtt-srv
|
- name: mqtt-srv
|
||||||
tags: mqtt-srv
|
role: mqtt-srv
|
||||||
|
tags: mqtt-srv
|
||||||
|
- name: vnc_server
|
||||||
|
role: vnc_server
|
||||||
|
tags: vnc_server
|
||||||
|
- name: promtail
|
||||||
|
role: promtail
|
||||||
|
tags: promtail
|
||||||
|
- name: sudoers
|
||||||
|
role: sudoers
|
||||||
|
tags: sudoers
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
---
|
# requirements.yml
|
||||||
|
# ansible-galaxy collection install -r collections/requirements.yml --force
|
||||||
collections:
|
collections:
|
||||||
- name: community.general
|
- name: community.general
|
||||||
|
source: https://galaxy.ansible.com
|
||||||
|
- name: community.docker
|
||||||
|
1
hosts
1
hosts
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
# Ex 1: Ungrouped hosts, specify before any group headers.
|
# Ex 1: Ungrouped hosts, specify before any group headers.
|
||||||
|
|
||||||
|
|
||||||
#green.example.com
|
#green.example.com
|
||||||
#blue.example.com
|
#blue.example.com
|
||||||
#192.168.100.1
|
#192.168.100.1
|
||||||
|
@ -73,7 +73,7 @@ datacenter:
|
|||||||
ansible_winrm_kerberos_delegation: true
|
ansible_winrm_kerberos_delegation: true
|
||||||
mqtt_srv:
|
mqtt_srv:
|
||||||
children:
|
children:
|
||||||
servers:
|
servers1:
|
||||||
hosts:
|
hosts:
|
||||||
rpi5-1.home.lan:
|
rpi5-1.home.lan:
|
||||||
rpi5.home.lan:
|
rpi5.home.lan:
|
||||||
@ -110,13 +110,42 @@ datacenter:
|
|||||||
|
|
||||||
containers:
|
containers:
|
||||||
children:
|
children:
|
||||||
|
docker_servers:
|
||||||
|
children:
|
||||||
|
router:
|
||||||
|
hosts:
|
||||||
|
router.home.lan:
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
ansible_ssh_user: root
|
||||||
|
ansible_ssh_private_key_file: ssh_key.pem
|
||||||
|
srv:
|
||||||
|
hosts:
|
||||||
|
rpi5.home.lan:
|
||||||
|
m-server.home.lan:
|
||||||
|
vars:
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
ansible_ssh_user: jd
|
||||||
|
ansible_become_password: l4c1j4yd33Du5lo
|
||||||
|
ansible_ssh_private_key_file: ssh_key.pem
|
||||||
|
identity_file: ssh_key.pem
|
||||||
|
ns:
|
||||||
|
hosts:
|
||||||
|
nas.home.lan:
|
||||||
|
vars:
|
||||||
|
ansible_ssh_user: admin
|
||||||
|
become_method: su
|
||||||
|
become_user: admin
|
||||||
|
ansible_ssh_private_key_file: ssh_key.pem
|
||||||
|
# ansible_user: admin
|
||||||
|
# ansible_pass: l4c1!j4yd33?Du5lo1
|
||||||
|
ansible_python_interpreter: /share/ZFS530_DATA/.qpkg/QPython312/bin/python3
|
||||||
servers:
|
servers:
|
||||||
hosts:
|
hosts:
|
||||||
rpi5-1.home.lan:
|
|
||||||
rpi5.home.lan:
|
rpi5.home.lan:
|
||||||
m-server.home.lan:
|
m-server.home.lan:
|
||||||
fog.home.lan:
|
amd.home.lan:
|
||||||
omv.home.lan:
|
rack.home.lan:
|
||||||
vars:
|
vars:
|
||||||
ansible_python_interpreter: /usr/bin/python3
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
ansible_ssh_user: jd
|
ansible_ssh_user: jd
|
||||||
|
30
jaydee.yml
30
jaydee.yml
@ -1,15 +1,17 @@
|
|||||||
$ANSIBLE_VAULT;1.1;AES256
|
$ANSIBLE_VAULT;1.1;AES256
|
||||||
64653733616336656435326432346561323838316463303932623433633565636333383264353564
|
34653034626436373537323430316462643663336164613763306336333038346562356565393036
|
||||||
6564633266633362346565303764313735356437656534640a306435383934313333313761303433
|
3964393861323439333839383061303864326235306665620a346233313633393135366362326464
|
||||||
63373839383236663233316330343161623435626334303934626161626664363833346134363931
|
63643039363635646131323365313833643864373637346536663831613837353833343030623366
|
||||||
6163623238373132340a346530336337313238353233633332383563343366383538343062353637
|
3038303063393565350a613439646161363330626566646264313939653339383439623532636638
|
||||||
32646562343166393737346330306439373230663137383430313532383064633765643031653264
|
38646433353765396136333236656535636235313639393565306636376438346362646438613835
|
||||||
37663134613538636639376439383530623432353332633938623362336539653864663634353261
|
62663031333832666262616365343831353530646263383932373666386631633430626363363966
|
||||||
36663266323566666361353065643239363365626264666131393033346561666562363836626665
|
61396336303365306135363039303032646137613330646434366638633738363064356132383439
|
||||||
36646138653834306564363965343338613936306334343733366633666435363636333436356538
|
36346432306531356333313963353463626232613563653331396334656539643531343136636635
|
||||||
66343034646631366131353366343136636136633162663535343939636431326534353962393361
|
31613762383664353930653165313461626133336161353639303662666234356138373539376161
|
||||||
30663331376563653935666565333466363562656130663462646639626138613365636533646333
|
30653837316266356136353132373663396365633434393166383230363263326139316362383766
|
||||||
66626131633039373064396132626232626336653434613966363466393739383030346635623165
|
64303738393663343636616437346535346566346536616663333866613966343563306265633064
|
||||||
31613131656336363966383239356137393163613036343638363834353639636431626634613031
|
66333331393861626637616330333463636135316466616532373663663464613034656337363437
|
||||||
39666239323936343732616234353465613066386362303265323436373435363864663531616234
|
62653333653838326632643238616638313935383532303233643132303637653963626363633662
|
||||||
6639666332643335623237623366666465633437343663303736
|
33646161373931386133353338643462306635393866656662376234396533376431366134653536
|
||||||
|
36363835346434323338363465336166303161633732333232653861646136326334616261653462
|
||||||
|
66376139313433383665
|
||||||
|
8
playbooks/00_start_containers_rpi5.yml
Executable file
8
playbooks/00_start_containers_rpi5.yml
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
- hosts: rpi5.home.lan
|
||||||
|
name: Start containers rpi5
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Start containers
|
||||||
|
ansible.builtin.shell: "docker start {{ item }}"
|
||||||
|
register: containers
|
||||||
|
with_items: ["HomeAssistant","webhub-web-1","heimdall","pihole","mosquitto-mosquitto-1","mailu3-redis-1","mailu3-webmail-1","mailu3-resolver-1","mailu3-antispam-1","mailu3-webdav-1","mailu3-smtp-1","mailu3-antivirus-1","mailu3-fts_attachments-1","mailu3-oletools-1","mailu3-admin-1","mailu3-front-1","mailu3-fetchmail-1","mailu3-imap-1","matter-server","piper-en","openwakeword","whisper-en","auth-worker-1","auth-server-1","auth-authentik_ldap-1","ak-outpost-ldap","auth-redis-1","auth-postgresql-1","nginx-app-1"]
|
14
playbooks/00_stop_containers_rpi5.yml
Executable file
14
playbooks/00_stop_containers_rpi5.yml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
- hosts: rpi5.home.lan
|
||||||
|
name: Stop rpi5
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Get running packages
|
||||||
|
ansible.builtin.shell: "docker ps|awk '{print $NF}'"
|
||||||
|
register: containers
|
||||||
|
- debug:
|
||||||
|
msg: "{{ containers.stdout_lines }}"
|
||||||
|
- name: Stop containers
|
||||||
|
ansible.builtin.shell: "docker stop {{ item }}"
|
||||||
|
register: containers
|
||||||
|
when: item != "NAMES" and item != "watchtower-watchtower-1"
|
||||||
|
with_items: "{{ containers.stdout_lines }}"
|
16
playbooks/00_sync_rpi5.yml
Executable file
16
playbooks/00_sync_rpi5.yml
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
- hosts: rpi5.home.lan
|
||||||
|
name: Sync rpi5
|
||||||
|
become: true
|
||||||
|
tasks:
|
||||||
|
- name: Get running packages
|
||||||
|
ansible.builtin.shell: "docker ps|awk '{print $NF}'"
|
||||||
|
register: containers
|
||||||
|
- debug:
|
||||||
|
msg: "{{ containers.stdout_lines }}"
|
||||||
|
- name: Stop containers
|
||||||
|
ansible.builtin.shell: "docker stop {{ item }}"
|
||||||
|
register: containers
|
||||||
|
when: item != "NAMES" and item != "watchtower-watchtower-1"
|
||||||
|
with_items: "{{ containers.stdout_lines }}"
|
||||||
|
- name: Sync data
|
||||||
|
ansible.builtin.shell: "/myapps/venv/bin/python3 /myapps/omv_backup.py -r all"
|
@ -1,55 +1,90 @@
|
|||||||
- hosts: nas
|
- hosts: m-server.home.lan
|
||||||
name: Build tasmota
|
name: Build tasmota
|
||||||
ignore_unreachable: false
|
ignore_unreachable: false
|
||||||
# vars:
|
# vars:
|
||||||
# DOCKER_IMAGE: docker-tasmota
|
# DOCKER_IMAGE: docker-tasmota
|
||||||
# FWS: tasmota
|
# FWS: tasmota
|
||||||
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: Fetch tasmota
|
- name: Change conf
|
||||||
ansible.builtin.shell:
|
community.general.git_config:
|
||||||
cmd: 'git fetch https://github.com/arendst/Tasmota.git {{ BRANCH }}'
|
name: safe.director
|
||||||
chdir: /share/docker_data/docker-tasmota/Tasmota
|
scope: global
|
||||||
when: inventory_hostname in groups['nas']
|
value: /share/docker_data/docker-tasmota/Tasmota
|
||||||
- name: Checkout tasmota branch
|
|
||||||
ansible.builtin.shell:
|
|
||||||
cmd: 'git checkout --force {{ BRANCH }}'
|
|
||||||
chdir: /share/docker_data/docker-tasmota/Tasmota
|
|
||||||
when: inventory_hostname in groups['nas']
|
|
||||||
|
|
||||||
- name: Pull tasmota
|
# - name: Pull tasmota
|
||||||
ansible.builtin.shell:
|
# ansible.builtin.shell:
|
||||||
cmd: 'git pull'
|
# cmd: 'git config --global --add safe.directory /share/docker_data/docker-tasmota/Tasmota'
|
||||||
chdir: /share/docker_data/docker-tasmota/Tasmota
|
|
||||||
when: inventory_hostname in groups['nas']
|
- name: Checkout a github repo and use refspec to fetch all pull requests
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: 'https://github.com/arendst/Tasmota.git'
|
||||||
|
dest: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
version: '{{ BRANCH }}'
|
||||||
|
|
||||||
|
# - name: Fetch tasmota
|
||||||
|
# ansible.builtin.shell:
|
||||||
|
# cmd: 'git fetch https://github.com/arendst/Tasmota.git {{ BRANCH }}'
|
||||||
|
# chdir: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
|
||||||
|
|
||||||
|
- name: Git checkout
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: 'https://github.com/arendst/Tasmota.git'
|
||||||
|
dest: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
version: '{{ BRANCH }}'
|
||||||
|
|
||||||
|
# - name: Checkout tasmota branch
|
||||||
|
# ansible.builtin.shell:
|
||||||
|
# cmd: 'git checkout --force {{ BRANCH }}'
|
||||||
|
# chdir: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
- name: Just get information about the repository whether or not it has already been cloned locally
|
||||||
|
ansible.builtin.git:
|
||||||
|
repo: https://github.com/arendst/Tasmota.git
|
||||||
|
dest: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
update: true
|
||||||
|
|
||||||
|
# - name: Pull tasmota
|
||||||
|
# ansible.builtin.shell:
|
||||||
|
# cmd: 'git pull'
|
||||||
|
# chdir: /share/docker_data/docker-tasmota/Tasmota
|
||||||
|
|
||||||
- name: Copy platformio_override
|
- name: Copy platformio_override
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: 'cp platformio_override.ini Tasmota/platformio_override.ini'
|
cmd: 'cp platformio_override.ini Tasmota/platformio_override.ini'
|
||||||
chdir: /share/docker_data/docker-tasmota/
|
chdir: /share/docker_data/docker-tasmota/
|
||||||
when: inventory_hostname in groups['nas']
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
- name: Copy user_config_override
|
- name: Copy user_config_override
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: 'cp user_config_override.h Tasmota/tasmota/user_config_override.h'
|
cmd: 'cp user_config_override.h Tasmota/tasmota/user_config_override.h'
|
||||||
chdir: /share/docker_data/docker-tasmota/
|
chdir: /share/docker_data/docker-tasmota/
|
||||||
when: inventory_hostname in groups['nas']
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
- name: Build tasmota
|
- name: Build tasmota
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: '/share/ZFS530_DATA/.qpkg/container-station/bin/docker run --rm -v /share/docker_data/docker-tasmota/Tasmota:/tasmota -u $UID:$GID {{ DOCKER_IMAGE }} -e {{ FWS }}'
|
cmd: 'docker run --rm -v /share/docker_data/docker-tasmota/Tasmota:/tasmota -u 0:0 {{ DOCKER_IMAGE }} -e {{ FWS }}'
|
||||||
chdir: /share/docker_data/docker-tasmota/
|
chdir: /share/docker_data/docker-tasmota/
|
||||||
when: FWS != "all"
|
when: FWS != "all"
|
||||||
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
- name: Build tasmota
|
- name: Build tasmota
|
||||||
ansible.builtin.shell:
|
ansible.builtin.command:
|
||||||
cmd: '/share/ZFS530_DATA/.qpkg/container-station/bin/docker run --rm -v /share/docker_data/docker-tasmota/Tasmota:/tasmota -u $UID:$GID {{ DOCKER_IMAGE }}'
|
cmd: 'docker run --rm -v /share/docker_data/docker-tasmota/Tasmota:/tasmota -u 0:0 {{ DOCKER_IMAGE }}'
|
||||||
chdir: /share/docker_data/docker-tasmota/
|
chdir: /share/docker_data/docker-tasmota/
|
||||||
when: FWS == "all"
|
when: FWS == "all"
|
||||||
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
- name: Create a directory if it does not exist
|
- name: Create a directory if it does not exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /share/docker_data/webhub/fw/{{ BRANCH }}
|
path: /share/docker_data/webhub/fw/{{ BRANCH }}
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
|
|
||||||
- name: Build tasmota
|
- name: Build tasmota
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: 'mv /share/docker_data/docker-tasmota/Tasmota/build_output/firmware/* /share/docker_data/webhub/fw/{{ BRANCH }}'
|
cmd: 'mv /share/docker_data/docker-tasmota/Tasmota/build_output/firmware/* /share/docker_data/webhub/fw/{{ BRANCH }}/'
|
||||||
when: inventory_hostname in groups['nas']
|
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
- hosts: nas
|
|
||||||
name: Sync mailu
|
|
||||||
ignore_unreachable: false
|
|
||||||
tasks:
|
|
||||||
- name: Syncing all
|
|
||||||
ansible.builtin.shell: 'rsync -avh --delete root@192.168.77.189:/srv/dev-disk-by-uuid-02fbe97a-cd9a-4511-8bd5-21f8516353ee/docker_data/latest/{{ CONTAINERS }} /share/docker_data/ --exclude="home-assistant.log*" --exclude="gitlab/logs/*"'
|
|
||||||
#ansible.builtin.shell: 'rsync -avh --delete /share/docker_data/{mailu2,webhub,nginx,heimdall} root@192.168.77.238:/share/docker_data/ --exclude="home-assistant.log*" --exclude="gitlab/logs/*"'
|
|
||||||
#ansible.builtin.shell: 'ls -la'
|
|
||||||
when: inventory_hostname in groups['nas']
|
|
||||||
# loop: '{{ CONTAINERS }}'
|
|
@ -1,90 +1,173 @@
|
|||||||
- hosts: containers
|
- hosts: docker_servers
|
||||||
name: Switch mailu to second
|
name: Switch server
|
||||||
|
|
||||||
ignore_unreachable: false
|
ignore_unreachable: false
|
||||||
vars:
|
|
||||||
arch_name: docker_mailu2_data
|
|
||||||
containers:
|
|
||||||
- nginx-app-1
|
|
||||||
- heimdall
|
|
||||||
- mailu2-admin-1
|
|
||||||
- mailu2-antispam-1
|
|
||||||
- mailu2-antivirus-1
|
|
||||||
- mailu2-fetchmail-1
|
|
||||||
- mailu2-front-1
|
|
||||||
- mailu2-imap-1
|
|
||||||
- mailu2-oletools-1
|
|
||||||
- mailu2-redis-1
|
|
||||||
- mailu2-resolver-1
|
|
||||||
- mailu2-smtp-1
|
|
||||||
- mailu2-webdav-1
|
|
||||||
- mailu2-webmail-1
|
|
||||||
- HomeAssistant
|
|
||||||
- mosquitto-mosquitto-1
|
|
||||||
- gitlab
|
|
||||||
- watchtower-watchtower-1
|
|
||||||
- kestra-kestra-1
|
|
||||||
- kestra-postgres-1
|
|
||||||
- authentik-worker-1
|
|
||||||
- authentik-server-1
|
|
||||||
- authentik-redis-1
|
|
||||||
- authentik-postgresql-1
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Start mailu containers
|
- name: Reconfigure swap size
|
||||||
command: "docker start {{ containers | join(' ') }}"
|
ansible.builtin.lineinfile:
|
||||||
become: true
|
path: /etc/sysctl.conf
|
||||||
|
regexp: "^net.ipv4.igmp_max_memberships =.*"
|
||||||
|
line: "net.ipv4.igmp_max_memberships = 1024"
|
||||||
|
create: true
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
- name: Start containers
|
||||||
|
shell: docker start `docker ps -a |awk '{ print $NF }'|grep -v NAME |xargs`
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
when: inventory_hostname in groups['raspberrypi5']
|
when: inventory_hostname == destination and inventory_hostname != "nas.home.lan"
|
||||||
|
- name: Start containers
|
||||||
- name: Get ruleset
|
shell: docker exec -it gitlab update-permissions
|
||||||
command: nvram get vts_rulelist
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
when: inventory_hostname in groups['router']
|
ignore_errors: true
|
||||||
register: ruleset
|
when: inventory_hostname == destination and inventory_hostname != "nas.home.lan and inventory_hostname != "rpi5.home.lan"
|
||||||
|
|
||||||
- name: Print the gateway for each host when defined
|
|
||||||
ansible.builtin.debug:
|
|
||||||
msg: "var is {{ ruleset.stdout }}"
|
|
||||||
when: inventory_hostname in groups['router']
|
|
||||||
|
|
||||||
|
|
||||||
- name: Print the gateway for each host when defined
|
- name: Start containers
|
||||||
ansible.builtin.debug:
|
shell: /share/ZFS530_DATA/.qpkg/container-station/bin/docker exec -it gitlab update-permissions
|
||||||
msg: "var is {{ destination }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
when: inventory_hostname in groups['router']
|
ignore_errors: true
|
||||||
|
when: inventory_hostname == destination and inventory_hostname == "nas.home.lan"
|
||||||
|
|
||||||
- name: initialize variables
|
|
||||||
set_fact:
|
- name: Start containers
|
||||||
regexp: "\\g<1>{{ destination }}\\3"
|
shell: /share/ZFS530_DATA/.qpkg/container-station/bin/docker start `/share/ZFS530_DATA/.qpkg/container-station/bin/docker ps -a |awk '{ print $NF }'|grep -v NAME |xargs`
|
||||||
when: inventory_hostname in groups['router']
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
ignore_errors: true
|
||||||
|
when: inventory_hostname == destination and inventory_hostname == "nas.home.lan"
|
||||||
|
|
||||||
- set_fact:
|
- name: Get Authentification token
|
||||||
app_path: "{{ ruleset.stdout | regex_replace('(\\<MAIL_SERVER\\>[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', regexp) | regex_replace('(\\<WEB_SERVER\\>[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', regexp) }}"
|
ansible.builtin.uri:
|
||||||
when: inventory_hostname in groups['router']
|
url: http://localhost:9380/api/auth
|
||||||
|
method: POST
|
||||||
|
body_format: json
|
||||||
|
body: {"password":"l4c1j4yd33Du5lo"}
|
||||||
|
register: login
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
# - debug:
|
||||||
|
# msg: "{{ login.json.session }}"
|
||||||
|
|
||||||
|
- name: Get Config
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: http://localhost:9380/api/config
|
||||||
|
method: GET
|
||||||
|
headers:
|
||||||
|
X-FTL-SID: "{{ login.json.session.sid }}"
|
||||||
|
register: old_config
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
# - debug:
|
||||||
|
# msg: "{{ old_config.json.config.dns.cnameRecords }}"
|
||||||
|
|
||||||
|
- name: Parse config
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
jsondata: "{{ old_config }}"
|
||||||
|
|
||||||
|
- name: New records for nas
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
new_data: ["mqtt.home.lan,nas.home.lan","media.home.lan,nas.home.lan","ldap.home.lan,nas.home.lan","webhub.home.lan,nas.home.lan","semaphore.home.lan,nas.home.lan","active.home.lan,nas.home.lan"]
|
||||||
|
when: destination == 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: New records for m-server
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
new_data: ["mqtt.home.lan,m-server.home.lan","media.home.lan,m-server.home.lan","ldap.home.lan,m-server.home.lan","webhub.home.lan,m-server.home.lan","semaphore.home.lan,m-server.home.lan","active.home.lan,m-server.home.lan"]
|
||||||
|
when: destination == 'm-server.home.lan'
|
||||||
|
|
||||||
|
- name: New records for rpi5
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
new_data: ["mqtt.home.lan,rpi5.home.lan","media.home.lan,rpi5.home.lan","ldap.home.lan,rpi5.home.lan","webhub.home.lan,rpi5.home.lan","semaphore.home.lan,rpi5.home.lan","active.home.lan,rpi5.home.lan"]
|
||||||
|
when: destination == 'rpi5.home.lan'
|
||||||
|
|
||||||
|
|
||||||
- name: Print the gateway for each host when defined
|
# - debug:
|
||||||
ansible.builtin.debug:
|
# msg: "{{ new_data }}"
|
||||||
msg: "var is {{ app_path }}"
|
|
||||||
when: inventory_hostname in groups['router']
|
- name: Set new values
|
||||||
|
ansible.utils.update_fact:
|
||||||
|
updates:
|
||||||
|
- path: jsondata.json.config.dns.cnameRecords
|
||||||
|
value: "{{ new_data }}"
|
||||||
|
register: new_config
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
- name: Patch config
|
||||||
- name: Pause for 60 seconds
|
ansible.builtin.uri:
|
||||||
ansible.builtin.pause:
|
url: http://localhost:9380/api/config
|
||||||
seconds: 60
|
method: PATCH
|
||||||
|
body: "{{ new_config.jsondata.json |to_json}}"
|
||||||
- name: Set new ruleset
|
headers:
|
||||||
command: nvram set vts_rulelist="{{ app_path }}"
|
X-FTL-SID: "{{ login.json.session.sid }}"
|
||||||
when: inventory_hostname in groups['router']
|
Content-Type: application/json
|
||||||
|
register: _result
|
||||||
- name: Nvram commit
|
until: _result.status == 200
|
||||||
command: nvram commit
|
retries: 3 # 720 * 5 seconds = 1hour (60*60/5)
|
||||||
when: inventory_hostname in groups['router']
|
delay: 5 # Every 5 seconds
|
||||||
|
register: _result
|
||||||
- name: Restart firewall
|
until: _result.status == 200
|
||||||
command: service restart_firewall
|
retries: 3 # 720 * 5 seconds = 1hour (60*60/5)
|
||||||
when: inventory_hostname in groups['router']
|
delay: 5 # Every 5 seconds
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Sleep for 30 seconds and continue with play
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 10
|
||||||
|
- name: Logout
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: http://localhost:9380/api/auth
|
||||||
|
method: DELETE
|
||||||
|
status_code: 204
|
||||||
|
headers:
|
||||||
|
X-FTL-SID: "{{ login.json.session.sid }}"
|
||||||
|
when: inventory_hostname != "router.home.lan"
|
||||||
|
ignore_errors: true
|
||||||
|
- name: Setting up resolv.conf
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/resolv.conf"
|
||||||
|
content: |
|
||||||
|
nameserver 192.168.77.101
|
||||||
|
nameserver 192.168.77.106
|
||||||
|
nameserver 192.168.77.238
|
||||||
|
options rotate
|
||||||
|
options timeout:1
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
|
|
||||||
|
# until: _result.status == 204
|
||||||
|
# retries: 3 # 720 * 5 seconds = 1hour (60*60/5)
|
||||||
|
# delay: 5 # Every 5 seconds
|
||||||
|
- name: Sleep for 60 seconds and continue with play
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 60
|
||||||
|
|
||||||
|
- name: Reconfigurte router containers
|
||||||
|
shell: python3 /root/unifi-api/unifi.py -s -d "{{ destination.split('.')[0] }}"
|
||||||
|
when: inventory_hostname == "router.home.lan"
|
||||||
|
|
||||||
|
- name: Stop containers
|
||||||
|
shell: docker stop `docker ps -a |awk '{ print $NF }'|egrep -v "NAME|^pihole$|watchtower|portainer" |xargs`
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
ignore_errors: true
|
||||||
|
when: inventory_hostname != destination and inventory_hostname != "nas.home.lan" and inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
- name: Restart containers
|
||||||
|
shell: docker restart nginx-app-1
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
when: inventory_hostname == destination
|
||||||
|
|
||||||
|
- name: Stop containers
|
||||||
|
shell: /share/ZFS530_DATA/.qpkg/container-station/bin/docker stop `/share/ZFS530_DATA/.qpkg/container-station/bin/docker ps -a |awk '{ print $NF }'|egrep -v "NAME|pihole|watchtower" |xargs`
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
ignore_errors: true
|
||||||
|
when: inventory_hostname != destination and inventory_hostname == "nas.home.lan" and inventory_hostname != "router.home.lan"
|
||||||
|
|
||||||
|
- name: Sleep for 120 seconds and continue with play
|
||||||
|
ansible.builtin.wait_for:
|
||||||
|
timeout: 120
|
||||||
|
# - name: Restart containers
|
||||||
|
# shell: docker restart nginx-app-1
|
||||||
|
# become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
# when: inventory_hostname == destination
|
||||||
|
|
||||||
|
|
15
playbooks/switch_destination_test.yaml
Executable file
15
playbooks/switch_destination_test.yaml
Executable file
@ -0,0 +1,15 @@
|
|||||||
|
- hosts: datacenter
|
||||||
|
name: Switch server
|
||||||
|
ignore_unreachable: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: Unifi Modifi
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: http://192.168.77.101:8123/api/webhook/-WcEse1k5QxIBlQu5B0u-5Esb?server=nas
|
||||||
|
method: POST
|
||||||
|
when: inventory_hostname == destination and destination == "nas.home.lan"
|
||||||
|
- name: Unifi Modifi
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: http://192.168.77.101:8123/api/webhook/-WcEse1k5QxIBlQu5B0u-5Esb?server=m-server
|
||||||
|
method: POST
|
||||||
|
when: inventory_hostname == destination and destination == "m-server.home.lan"
|
@ -9,12 +9,12 @@
|
|||||||
mode: '0700'
|
mode: '0700'
|
||||||
- name: Download id_rsa
|
- name: Download id_rsa
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: http://192.168.77.101:48000/ssh/id_rsa
|
url: http://192.168.77.238:48000/ssh/id_rsa
|
||||||
dest: ~/.ssh/id_rsa
|
dest: ~/.ssh/id_rsa
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
- name: Download id_rsa.pub
|
- name: Download id_rsa.pub
|
||||||
ansible.builtin.get_url:
|
ansible.builtin.get_url:
|
||||||
url: http://192.168.77.101:48000/ssh/id_rsa.pub
|
url: http://192.168.77.238:48000/ssh/id_rsa.pub
|
||||||
dest: ~/.ssh/id_rsa.pub
|
dest: ~/.ssh/id_rsa.pub
|
||||||
mode: '0600'
|
mode: '0600'
|
||||||
- name: get remote file contents
|
- name: get remote file contents
|
||||||
|
@ -1,42 +1,109 @@
|
|||||||
- block:
|
- name: Setup autofs
|
||||||
- name: include vault
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.include_vars:
|
block:
|
||||||
file: jaydee.yml
|
- name: Include vault
|
||||||
- name: Install autofs
|
ansible.builtin.include_vars:
|
||||||
ansible.builtin.apt:
|
file: jaydee.yml
|
||||||
name:
|
- name: Install autofs
|
||||||
- autofs
|
ansible.builtin.apt:
|
||||||
- cifs-utils
|
name:
|
||||||
state: present
|
- autofs
|
||||||
|
- cifs-utils
|
||||||
|
state: present
|
||||||
|
|
||||||
- name: Creating a file with content
|
- name: Creating a file with content
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: "/etc/auto.auth"
|
dest: "/etc/auto.auth"
|
||||||
content: |
|
content: |
|
||||||
username={{ samba_user }}
|
username={{ samba_user }}
|
||||||
password={{ samba_password }}
|
password={{ samba_password }}
|
||||||
|
mode: '0600'
|
||||||
- name: Creating a file with content
|
owner: root
|
||||||
copy:
|
group: root
|
||||||
dest: "/etc/auto.nas"
|
- name: Creating a file with content
|
||||||
content: |
|
ansible.builtin.copy:
|
||||||
nas-data -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Data
|
dest: "/etc/auto.m-server"
|
||||||
nas-docker-data -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/docker_data
|
content: |
|
||||||
nas-photo -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Photo
|
docker_data -fstype=nfs m-server.home.lan:/share/docker_data
|
||||||
nas-public -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Public
|
downloads -fstype=nfs m-server.home.lan:/media/data/downloads
|
||||||
nas-install -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/install
|
mode: '0600'
|
||||||
nas-media -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Media
|
owner: root
|
||||||
nas-downloads -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/downloads
|
group: root
|
||||||
|
- name: Creating a file with content
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/auto.nas-movies"
|
||||||
|
content: |
|
||||||
|
movies -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/movies
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent Server
|
- name: Creating a file with content
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.copy:
|
||||||
path: /etc/auto.master
|
dest: "/etc/auto.nas-music"
|
||||||
regexp: "^/media/nas.*"
|
content: |
|
||||||
insertafter: '^/media/nas'
|
music -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/music
|
||||||
line: "/media/nas /etc/auto.nas --timeout 360 --ghost"
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
- name: Restart docker service
|
- name: Creating a file with content
|
||||||
ansible.builtin.service:
|
ansible.builtin.copy:
|
||||||
name: autofs
|
dest: "/etc/auto.nas-shows"
|
||||||
state: restarted
|
content: |
|
||||||
become: true
|
shows -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/shows
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: Creating a file with content
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/auto.nas"
|
||||||
|
content: |
|
||||||
|
nas-data -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Data
|
||||||
|
nas-docker-data -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/docker_data
|
||||||
|
nas-photo -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Photo
|
||||||
|
nas-public -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/Public
|
||||||
|
nas-install -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/install
|
||||||
|
nas-downloads -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/downloads
|
||||||
|
nas-games -fstype=cifs,credentials=/etc/auto.auth,dir_mode=0755,file_mode=0755,uid=jd,rw ://nas.home.lan/qda_2
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
# - name: Reconfigure autofs Server
|
||||||
|
# ansible.builtin.lineinfile:
|
||||||
|
# path: /etc/auto.master
|
||||||
|
# regexp: "^/media/nas.*"
|
||||||
|
# insertafter: '^/media/nas'
|
||||||
|
# line: "/media/nas /etc/auto.nas --timeout 360 --ghost"
|
||||||
|
|
||||||
|
- name: Reconfigure autofs Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/auto.master
|
||||||
|
regexp: "^/media/data/music/nas.*"
|
||||||
|
line: /media/data/music/nas /etc/auto.nas-music --timeout 360 --ghost
|
||||||
|
- name: Reconfigure autofs Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/auto.master
|
||||||
|
regexp: "^/media/data/movies/nas.*"
|
||||||
|
line: /media/data/movies/nas /etc/auto.nas-movies --timeout 360 --ghost
|
||||||
|
- name: Reconfigure autofs Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/auto.master
|
||||||
|
regexp: "^/media/data/shows/nas.*"
|
||||||
|
line: /media/data/shows/nas /etc/auto.nas-shows --timeout 360 --ghost
|
||||||
|
|
||||||
|
|
||||||
|
- name: Reconfigure autofs Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/auto.master
|
||||||
|
line: /media/nas /etc/auto.nas --timeout 360 --ghost
|
||||||
|
- name: Reconfigure autofs Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/auto.master
|
||||||
|
line: /media/m-server /etc/auto.m-server --timeout 360 --ghost
|
||||||
|
|
||||||
|
- name: Restart docker service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: autofs
|
||||||
|
state: restarted
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
- name: Upgrade the full OS
|
- name: Upgrade
|
||||||
ansible.builtin.apt:
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
upgrade: full
|
block:
|
||||||
become: true
|
- name: Upgrade the full OS
|
||||||
- name: Upgrade flatpack
|
ansible.builtin.apt:
|
||||||
ansible.builtin.command: flatpak update -y
|
update_cache: true
|
||||||
become: true
|
upgrade: full
|
||||||
when: inventory_hostname == 'morefine.home.lan'
|
- name: Upgrade flatpack
|
||||||
|
ansible.builtin.command: flatpak update -y
|
||||||
|
when: inventory_hostname == 'morefine.home.lan'
|
||||||
|
33
roles/docker/files/ca.pem
Executable file
33
roles/docker/files/ca.pem
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFqTCCA5GgAwIBAgIUJ3kgn/onrwoKs+MqhsHo7RmF/20wDQYJKoZIhvcNAQEL
|
||||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|
-----END CERTIFICATE-----
|
32
roles/docker/files/server-cert.pem
Executable file
32
roles/docker/files/server-cert.pem
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIFkDCCA3igAwIBAgIUUYzivwquTJnP+9/Q/zb/0Ew+eVowDQYJKoZIhvcNAQEL
|
||||||
|
BQAwZDELMAkGA1UEBhMCU0sxETAPBgNVBAgMCFNsb3Zha2lhMQswCQYDVQQHDAJT
|
||||||
|
SzETMBEGA1UECgwKc2VjdG9ycS5ldTELMAkGA1UECwwCSVQxEzARBgNVBAMMCnNl
|
||||||
|
Y3RvcnEuZXUwHhcNMjUwMzExMTc1MDEzWhcNMjYwMzExMTc1MDEzWjAcMRowGAYD
|
||||||
|
VQQDDBFtLXNlcnZlci5ob21lLmxhbjCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCC
|
||||||
|
AgoCggIBALcgqTwwWnKeiHt1ZZQjoyZw/c/DbPwQnBuQVhNGF6RX7apXP/eY4Sf8
|
||||||
|
/l2y6awZd6vM4JyFonPENbll/dEVgFEPgwwiqiaBC9PuZIbC60LLYwpDUmaHXNAd
|
||||||
|
xgohSWOEc7uT1lcW2yn5n1A93JpoOScb/dAmjWPUYV3BqnKTtcqVs3a5SzWxnIqO
|
||||||
|
szWt97SZpRY3GWIAiOmFqcKE5gL7FkSaMyS81E/Qfct/37o5OHWpiBhzLZUyop1e
|
||||||
|
z9f7RrgDRzEoNlJisWFY/wF0xvmowkslL8QsYBTkfgofP7dEm8MOn0hJOFzuUY75
|
||||||
|
TAp+h6wiL0bhTab4XDOrFjFy5ivehICdDSal+IlNEmI9Zsziy/1gW7WXCMMgOXKn
|
||||||
|
xX7se2OFbHGCaf9NCn+0ODHev9ZeDni5SQsgyD3Zjyh3kc7AZ97M8jNJlCGb2QaJ
|
||||||
|
f/BF2Q9EzbQYHjor97r/+tMdvYkYNo9+FYoJH3yP+T378Tn+DFe8KthvbqCSF01t
|
||||||
|
aDdfc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HH5hYfS3ISt
|
||||||
|
kbaw2ARNqbcktQkWwA+W+rb83en/w3WG1v2vByKGCr1s4jHAhWtSLZhXx+PIYeT+
|
||||||
|
ml/kv+Y3W1T/lOcsytJrXug8t+g4nh9wYTnRl5YwruaKQjWF
|
||||||
|
-----END CERTIFICATE-----
|
52
roles/docker/files/server-key.pem
Executable file
52
roles/docker/files/server-key.pem
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIJQgIBADANBgkqhkiG9w0BAQEFAASCCSwwggkoAgEAAoICAQC3IKk8MFpynoh7
|
||||||
|
dWWUI6MmcP3Pw2z8EJwbkFYTRhekV+2qVz/3mOEn/P5dsumsGXerzOCchaJzxDW5
|
||||||
|
Zf3RFYBRD4MMIqomgQvT7mSGwutCy2MKQ1Jmh1zQHcYKIUljhHO7k9ZXFtsp+Z9Q
|
||||||
|
PdyaaDknG/3QJo1j1GFdwapyk7XKlbN2uUs1sZyKjrM1rfe0maUWNxliAIjphanC
|
||||||
|
hOYC+xZEmjMkvNRP0H3Lf9+6OTh1qYgYcy2VMqKdXs/X+0a4A0cxKDZSYrFhWP8B
|
||||||
|
dMb5qMJLJS/ELGAU5H4KHz+3RJvDDp9ISThc7lGO+UwKfoesIi9G4U2m+FwzqxYx
|
||||||
|
cuYr3oSAnQ0mpfiJTRJiPWbM4sv9YFu1lwjDIDlyp8V+7HtjhWxxgmn/TQp/tDgx
|
||||||
|
3r/WXg54uUkLIMg92Y8od5HOwGfezPIzSZQhm9kGiX/wRdkPRM20GB46K/e6//rT
|
||||||
|
Hb2JGDaPfhWKCR98j/k9+/E5/gxXvCrYb26gkhdNbWg3X3EbtKfqjWpVZA9q3LaI
|
||||||
|
SYIhLoc1SCKX6ntz/cjMswWIMKFzFCLYboOMDqPIBF8K+3IE0yvKcT0BpaNSS9Fr
|
||||||
|
gcaHbXRz/f1UJn90JII91tFEwD966YZ74P+UubaiEz+1vh1YxM0xIds9hRsc+Jbx
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SFiisjXYMRWa1S8udoGrZiSMtW5nxJB3pr
|
||||||
|
8Do8KIbee4JIgsG/2qet6ZiV4tU9bA6PmL0qrkdTVTLMBWRcS7FntFFT41Zin5UY
|
||||||
|
kPYt8tldqrgicrGCCc1afY7TtHbnHfMPXfeiq9kgrD2ze3ESJ0IfyAIIiJMIC4v3
|
||||||
|
QRInfPSKHnh8Ks7PEGAQ8OY0zwbvPKFJElsHYYDIG2xfSCDdN5ltUqZ15G/wrhQ/
|
||||||
|
C70CggEAHKhqoWElJNa3Ba4UscXKWL28cXRkMLdZGRngU5W9GLUQhDVYHdy+x5jU
|
||||||
|
5V4OnhCFo4Vq8uc2HsKnknhu/KGJ2gf3g8ASkILCG6aqB+0xZ+N6/dW0Yfft7vV4
|
||||||
|
az9azn2nEK6Pqiokm0ggc+UhZ4C6EKWY3Vefs0scxKBIx48aGDP0I/XwFrZpwdWC
|
||||||
|
Z/jlCjTZlJ+5G7VenkqWtIlJmXZ6zrRFkPKlmxSTKIrDTJaD0dcNmDrwe+au0x+y
|
||||||
|
YHMSo0gMN9W5pFN6LDc/JYXOkb995mkKXyzeRTFy+v2yFig6rSwBStwcSTsuNWAe
|
||||||
|
FOWrzZPSFGNqLJEHjZdIBAaDR6ER7A==
|
||||||
|
-----END PRIVATE KEY-----
|
@ -1,57 +1,165 @@
|
|||||||
- block:
|
- name: Setup docker
|
||||||
- name: Install docker
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.apt:
|
block:
|
||||||
name:
|
- name: Facts
|
||||||
- ca-certificates
|
ansible.builtin.setup:
|
||||||
- curl
|
|
||||||
- telnet
|
|
||||||
- net-tools
|
|
||||||
- python3-pip
|
|
||||||
- python3-dev
|
|
||||||
state: present
|
|
||||||
update_cache: true
|
|
||||||
- name: Get keys for raspotify
|
|
||||||
ansible.builtin.shell:
|
|
||||||
install -m 0755 -d /etc/apt/keyrings
|
|
||||||
|
|
||||||
- name: Get keys for raspotify
|
- name: Print arch
|
||||||
ansible.builtin.shell:
|
ansible.builtin.debug:
|
||||||
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
msg: "{{ ansible_architecture }}"
|
||||||
|
- name: Install docker dependencies
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- ca-certificates
|
||||||
|
- curl
|
||||||
|
- telnet
|
||||||
|
- net-tools
|
||||||
|
- python3-pip
|
||||||
|
- python3-dev
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
- name: Get keys for raspotify
|
||||||
|
ansible.builtin.command:
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
|
||||||
- name: Get keys for raspotify
|
|
||||||
ansible.builtin.shell:
|
|
||||||
chmod a+r /etc/apt/keyrings/docker.asc
|
|
||||||
|
|
||||||
- name: Get keys for raspotify
|
# - name: Add an Apt signing key to a specific keyring file
|
||||||
ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
# ansible.builtin.apt_key:
|
||||||
|
# url: https://download.docker.com/linux/debian/gpg
|
||||||
|
# keyring: /etc/apt/keyrings/docker.asc
|
||||||
|
# when:
|
||||||
|
# - ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
||||||
|
|
||||||
- name: Install docker
|
# - name: Get keys for raspotify
|
||||||
ansible.builtin.apt:
|
# ansible.builtin.shell:
|
||||||
name:
|
# curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
- docker-ce
|
# when:
|
||||||
- docker-ce-cli
|
# - ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
||||||
- containerd.io
|
|
||||||
- docker-buildx-plugin
|
|
||||||
- docker-compose-plugin
|
|
||||||
update_cache: true
|
|
||||||
|
|
||||||
- name: Create a directory docker.service.d
|
- name: Get keys for raspotify
|
||||||
ansible.builtin.file:
|
ansible.builtin.shell:
|
||||||
path: /etc/systemd/system/docker.service.d/
|
curl -fsSL https://download.docker.com/linux/raspbian/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
state: directory
|
when:
|
||||||
mode: '0755'
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
||||||
|
|
||||||
- name: Creating a file with content
|
- name: Add an Apt signing key to a specific keyring file
|
||||||
copy:
|
ansible.builtin.apt_key:
|
||||||
dest: "/etc/systemd/system/docker.service.d/override.conf"
|
url: https://download.docker.com/linux/ubuntu/gpg
|
||||||
content: |
|
keyring: /etc/apt/keyrings/docker.asc
|
||||||
[Service]
|
when:
|
||||||
ExecStart=
|
- ansible_distribution == "Ubuntu"
|
||||||
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375
|
|
||||||
notify: restart_docker
|
|
||||||
|
|
||||||
- name: Just force systemd to reread configs
|
# - name: Get keys for raspotify
|
||||||
ansible.builtin.systemd:
|
# ansible.builtin.shell:
|
||||||
daemon_reload: true
|
# curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||||||
|
# when:
|
||||||
|
# - ansible_distribution == "Ubuntu"
|
||||||
|
- name: Change file ownership, group and permissions
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/apt/keyrings/docker.asc
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
become: true
|
# - name: Get keys for raspotify
|
||||||
|
# ansible.builtin.shell:
|
||||||
|
# chmod a+r /etc/apt/keyrings/docker.asc
|
||||||
|
|
||||||
|
- name: Get keys for raspotify
|
||||||
|
ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
||||||
|
|
||||||
|
- name: Get keys for raspotify
|
||||||
|
ansible.builtin.shell: echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
when:
|
||||||
|
- ansible_distribution == "Ubuntu"
|
||||||
|
|
||||||
|
- name: Install docker
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- docker-ce
|
||||||
|
- docker-ce-cli
|
||||||
|
- containerd.io
|
||||||
|
- docker-buildx-plugin
|
||||||
|
- docker-compose-plugin
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Create a directory docker.service.d
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/system/docker.service.d/
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
- name: Create a directory for certs
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/docker/certs
|
||||||
|
state: directory
|
||||||
|
mode: '0700'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
|
||||||
|
- name: Copy files
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: server-key.pem
|
||||||
|
dest: /etc/docker/certs/
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Copy files
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: ca.pem
|
||||||
|
dest: /etc/docker/certs/
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Copy files
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: server-cert.pem
|
||||||
|
dest: /etc/docker/certs/
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Creating a file with content
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/systemd/system/docker.service.d/override.conf"
|
||||||
|
content: |
|
||||||
|
[Service]
|
||||||
|
ExecStart=
|
||||||
|
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --tlsverify --tlscacert=/etc/docker/certs/ca.pem --tlscert=/etc/docker/certs/server-cert.pem --tlskey=/etc/docker/certs/server-key.pem -H=0.0.0.0:2376
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
notify: restart_docker
|
||||||
|
when: mode == "cert"
|
||||||
|
|
||||||
|
# - name: Creating a file with content
|
||||||
|
# ansible.builtin.copy:
|
||||||
|
# dest: "/etc/systemd/system/docker.service.d/override.conf"
|
||||||
|
# content: |
|
||||||
|
# [Service]
|
||||||
|
# ExecStart=
|
||||||
|
# ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --tlsverify \
|
||||||
|
# --tlscacert=/etc/docker/certs/ca.pem --tlscert=/etc/docker/certs/server-cert.pem \
|
||||||
|
# --tlskey=/etc/docker/certs/server-key.pem -H=0.0.0.0:2376
|
||||||
|
# mode: '0600'
|
||||||
|
# owner: root
|
||||||
|
# group: root
|
||||||
|
# notify: restart_docker
|
||||||
|
# when: mode != "nocert"
|
||||||
|
|
||||||
|
- name: Just force systemd to reread configs
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
|
||||||
|
- name: Restart docker service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: docker
|
||||||
|
state: restarted
|
||||||
|
|
||||||
|
# - name: Get keys for raspotify
|
||||||
|
# ansible.builtin.shell: docker plugin install grafana/loki-docker-driver:3.3.2-{{ ansible_architecture }} --alias loki --grant-all-permissions
|
||||||
|
- name: Install a plugin
|
||||||
|
community.docker.docker_plugin:
|
||||||
|
plugin_name: grafana/loki-docker-driver:3.3.2
|
||||||
|
alias: loki
|
||||||
|
state: present
|
||||||
|
0
roles/fail2ban/files/action.d/banan.conf
Normal file → Executable file
0
roles/fail2ban/files/action.d/banan.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/bad-auth.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/bad-auth.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/nextcloud.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/nextcloud.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/sshd.conf
Normal file → Executable file
0
roles/fail2ban/files/filter.d/sshd.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/bad-auth.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/bad-auth.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/nextcloud.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/nextcloud.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/sshd.conf
Normal file → Executable file
0
roles/fail2ban/files/jail.d/sshd.conf
Normal file → Executable file
@ -1,39 +1,51 @@
|
|||||||
- block:
|
- name: Setup Fail2ban
|
||||||
- name: Install fail2ban packages
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.apt:
|
block:
|
||||||
name:
|
- name: Install fail2ban packages
|
||||||
- fail2ban
|
ansible.builtin.apt:
|
||||||
- sendmail
|
name:
|
||||||
- name: Copy files
|
- fail2ban
|
||||||
copy:
|
- sendmail
|
||||||
src: "{{ item }}"
|
# add line to /etc/hosts
|
||||||
dest: /etc/fail2ban/jail.d/
|
# 127.0.0.1 m-server localhost....
|
||||||
with_fileglob:
|
- name: Copy files
|
||||||
- "jail.d/*.conf"
|
ansible.builtin.copy:
|
||||||
|
src: "{{ item }}"
|
||||||
|
dest: /etc/fail2ban/jail.d/
|
||||||
|
mode: '0700'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
with_fileglob:
|
||||||
|
- "jail.d/*.conf"
|
||||||
|
|
||||||
- name: Copy files
|
- name: Copy files
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /etc/fail2ban/filter.d/
|
dest: /etc/fail2ban/filter.d/
|
||||||
with_fileglob:
|
mode: '0700'
|
||||||
- "filter.d/*.conf"
|
owner: root
|
||||||
|
group: root
|
||||||
|
with_fileglob:
|
||||||
|
- "filter.d/*.conf"
|
||||||
|
|
||||||
- name: Copy files
|
- name: Copy files
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ item }}"
|
src: "{{ item }}"
|
||||||
dest: /etc/fail2ban/action.d/
|
dest: /etc/fail2ban/action.d/
|
||||||
with_fileglob:
|
mode: '0700'
|
||||||
- "action.d/*.conf"
|
owner: root
|
||||||
|
group: root
|
||||||
|
with_fileglob:
|
||||||
|
- "action.d/*.conf"
|
||||||
|
|
||||||
- name: disable sendmail service
|
- name: Disable sendmail service
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: sendmail.service
|
name: sendmail.service
|
||||||
state: stopped
|
state: stopped
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
||||||
- name: Restart fail2ban service
|
- name: Restart fail2ban service
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: fail2ban.service
|
name: fail2ban.service
|
||||||
state: restarted
|
state: restarted
|
||||||
enabled: true
|
enabled: true
|
||||||
become: true
|
|
||||||
|
0
roles/hosts/files/hosts
Normal file
0
roles/hosts/files/hosts
Normal file
28
roles/hosts/tasks/main.yml
Executable file
28
roles/hosts/tasks/main.yml
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
- name: Hosts
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^192.168.77.101 .*"
|
||||||
|
line: "192.168.77.101 m-server m-server.home.lan"
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^192.168.77.106 .*"
|
||||||
|
line: "192.168.77.106 nas nas.home.lan"
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^192.168.77.238 .*"
|
||||||
|
line: "192.168.77.238 rpi5 rpi5.home.lan"
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^192.168.77.4 .*"
|
||||||
|
line: "192.168.77.4 amd amd.home.lan"
|
||||||
|
- name: Reconfigure hosts file
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/hosts"
|
||||||
|
regexp: "^192.168.77.55 .*"
|
||||||
|
line: "192.168.77.55 rack rack.home.lan"
|
@ -1,10 +1,12 @@
|
|||||||
- block:
|
- name: Setup matter server
|
||||||
- name: Reconfigure config
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
||||||
ansible.builtin.lineinfile:
|
block:
|
||||||
path: /etc/sysctl.conf
|
- name: Reconfigure config
|
||||||
regexp: "^Unet.ipv4.igmp_max_memberships.*"
|
ansible.builtin.lineinfile:
|
||||||
line: "net.ipv4.igmp_max_memberships = 75"
|
path: /etc/sysctl.conf
|
||||||
- name: Restart agent
|
regexp: "^Unet.ipv4.igmp_max_memberships.*"
|
||||||
ansible.builtin.shell: echo 76 > /proc/sys/net/ipv4/igmp_max_memberships
|
line: "net.ipv4.igmp_max_memberships = 80"
|
||||||
notify: restart_matter_server
|
- name: Restart agent
|
||||||
become: true
|
ansible.builtin.shell: echo 80 > /proc/sys/net/ipv4/igmp_max_memberships
|
||||||
|
notify: restart_matter_server
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
|
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Get config for nas
|
- name: Get config for nas
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf"
|
zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf"
|
||||||
@ -23,48 +23,49 @@
|
|||||||
# dest: /tmp/
|
# dest: /tmp/
|
||||||
- name: Install a .deb package from the internet11
|
- name: Install a .deb package from the internet11
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
deb: https://repo.zabbix.com/zabbix/7.2/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.2+ubuntu24.04_all.deb
|
||||||
when:
|
when:
|
||||||
- ansible_facts.architecture != "armv7l" and ( ansible_distribution == "Ubuntu" or ansible_distribution == "Linux Mint" )
|
- ansible_facts.architecture != "armv7l" and ( ansible_distribution == "Ubuntu1" or ansible_distribution == "Linux Mint" )
|
||||||
become: true
|
become: true
|
||||||
- name: Install a .deb package from the internet2
|
- name: Install a .deb package from the internet2
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
#deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
# deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
||||||
deb: https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
|
deb: https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 5
|
delay: 5
|
||||||
when:
|
when:
|
||||||
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
|
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
|
||||||
become: true
|
become: true
|
||||||
ignore_errors: true
|
failed_when: my_output.rc != 0
|
||||||
|
|
||||||
- name: Install a .deb package from the internet3
|
- name: Install a .deb package from the internet3
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
||||||
become: true
|
become: true
|
||||||
when:
|
when:
|
||||||
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
|
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
|
||||||
|
|
||||||
- name: Install a .deb package from the internet4
|
- name: Install a .deb package from the internet4
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
#deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
|
# deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
|
||||||
deb: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb
|
deb: https://repo.zabbix.com/zabbix/7.2/debian/pool/main/z/zabbix-release/zabbix-release_7.2-1+debian12_all.deb
|
||||||
when:
|
when:
|
||||||
- ansible_facts.architecture != "armv7l" and ansible_facts.architecture != "aarch64" and ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
- ansible_facts.architecture != "armv7l"
|
||||||
ignore_errors: true
|
- ansible_facts.architecture != "aarch64"
|
||||||
|
- ansible_distribution == "Debian"
|
||||||
|
- ansible_distribution_major_version == "12"
|
||||||
|
failed_when: my_output.rc != 0
|
||||||
become: true
|
become: true
|
||||||
# - name: Install a .deb package localy
|
|
||||||
# ansible.builtin.apt:
|
|
||||||
# deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
|
||||||
- name: Install zabbix packages
|
- name: Install zabbix packages
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
- zabbix-agent2
|
- zabbix-agent2
|
||||||
- zabbix-agent2-plugin-mongodb
|
- zabbix-agent2-plugin-mongodb
|
||||||
- zabbix-agent2-plugin-postgresql
|
- zabbix-agent2-plugin-postgresql
|
||||||
update_cache: yes
|
update_cache: false
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ignore_errors: true
|
failed_when: my_output.rc != 0
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent Server
|
- name: Reconfigure zabbix agent Server
|
||||||
@ -99,14 +100,14 @@
|
|||||||
regexp: "^Hostname=.*"
|
regexp: "^Hostname=.*"
|
||||||
line: "Hostname={{ inventory_hostname }}"
|
line: "Hostname={{ inventory_hostname }}"
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
insertafter: '^# UserParameter='
|
insertafter: '^# UserParameter='
|
||||||
regexp: "^UserParameter=system.certs.*"
|
regexp: "^UserParameter=system.certs.*"
|
||||||
line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py"
|
line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py"
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
@ -115,7 +116,7 @@
|
|||||||
insertafter: '^# UserParameter='
|
insertafter: '^# UserParameter='
|
||||||
regexp: "^UserParameter=system.certs.*"
|
regexp: "^UserParameter=system.certs.*"
|
||||||
line: "UserParameter=system.certs,python3 /usr/bin/cert_check2.py"
|
line: "UserParameter=system.certs,python3 /usr/bin/cert_check2.py"
|
||||||
when: inventory_hostname == 'm-server.home.lan'
|
when: inventory_hostname == 'm-server.home.lan'
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
@ -140,14 +141,14 @@
|
|||||||
regexp: "^HostMetadata=.*"
|
regexp: "^HostMetadata=.*"
|
||||||
insertafter: '^# HostMetadata='
|
insertafter: '^# HostMetadata='
|
||||||
line: "HostMetadata=server;jaydee"
|
line: "HostMetadata=server;jaydee"
|
||||||
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
- name: Add the user 'to group video
|
- name: Add the user 'to group video
|
||||||
ansible.builtin.user:
|
ansible.builtin.user:
|
||||||
name: zabbix
|
name: zabbix
|
||||||
groups: video
|
groups: video
|
||||||
append: yes
|
append: true
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
@ -160,6 +161,8 @@
|
|||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
||||||
- name: Restart agent
|
- name: Restart agent
|
||||||
ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart
|
ansible.builtin.command: /etc/init.d/ZabbixAgent.sh restart
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
changed_when: my_output.rc != 0
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
@ -1,116 +1,146 @@
|
|||||||
- block:
|
- name: Setup mqtt_srv
|
||||||
- name: include vault
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
||||||
ansible.builtin.include_vars:
|
block:
|
||||||
file: jaydee.yml
|
- name: Include vault
|
||||||
- name: Delete content & directory
|
ansible.builtin.include_vars:
|
||||||
ansible.builtin.file:
|
file: jaydee.yml
|
||||||
state: absent
|
- name: Delete content & directory
|
||||||
path: "{{ dest_folder }}"
|
ansible.builtin.file:
|
||||||
- name: GIT pull
|
state: absent
|
||||||
tags:
|
path: "{{ dest_folder }}"
|
||||||
- git_pull
|
- name: GIT pull
|
||||||
git:
|
tags:
|
||||||
repo: "https://{{ git_user | urlencode }}:{{ git_password_mqtt | urlencode }}@gitlab.sectorq.eu/jaydee/mqtt_srv.git"
|
- git_pull
|
||||||
dest: "{{ dest_folder }}"
|
ansible.builtin.git:
|
||||||
update: yes
|
repo: "https://{{ git_user | urlencode }}:{{ git_password_mqtt | urlencode }}@gitlab.sectorq.eu/jaydee/mqtt_srv.git"
|
||||||
clone: yes
|
dest: "{{ dest_folder }}"
|
||||||
version: main
|
update: true
|
||||||
- debug:
|
clone: true
|
||||||
msg: "{{ inventory_hostname }}"
|
version: main
|
||||||
|
- name: Print message
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: "{{ inventory_hostname }}"
|
||||||
|
- name: Create dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/mqtt_srv/
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Create dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /myapps/mqtt_srv/
|
||||||
|
recurse: true
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Upload service config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ dest_folder }}/mqtt_srv.service"
|
||||||
|
dest: /etc/systemd/system/mqtt_srv.service
|
||||||
|
remote_src: true
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Upload service config
|
- name: Upload service script
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ dest_folder }}/mqtt_srv.service"
|
src: "{{ dest_folder }}/mqtt_srv.py"
|
||||||
dest: /etc/systemd/system/mqtt_srv.service
|
dest: /myapps/mqtt_srv/mqtt_srv.py
|
||||||
remote_src: true
|
mode: '0755'
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
owner: root
|
||||||
|
group: root
|
||||||
- name: Upload service script
|
remote_src: true
|
||||||
ansible.builtin.copy:
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
src: "{{ dest_folder }}/mqtt_srv.py"
|
- name: Upload service req
|
||||||
dest: /usr/bin/mqtt_srv.py
|
ansible.builtin.copy:
|
||||||
mode: '755'
|
src: "{{ dest_folder }}/requirements.txt"
|
||||||
owner: root
|
dest: /myapps/mqtt_srv/requirements.txt
|
||||||
remote_src: true
|
mode: '0755'
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
owner: root
|
||||||
|
group: root
|
||||||
- name: Upload service script config
|
remote_src: true
|
||||||
ansible.builtin.copy:
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
src: "{{ dest_folder }}/mqtt_srv.cfg"
|
|
||||||
dest: /etc/mqtt_srv/mqtt_srv.cfg
|
|
||||||
mode: '755'
|
|
||||||
owner: root
|
|
||||||
remote_src: true
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
# - name: Upload service script1
|
|
||||||
# ansible.builtin.copy:
|
|
||||||
# src: scripts/mqtt_srv.sh
|
|
||||||
# dest: /jffs/scripts/mqtt_srv/
|
|
||||||
# mode: '755'
|
|
||||||
# owner: admin
|
|
||||||
# when: inventory_hostname in groups['router']
|
|
||||||
# become: false
|
|
||||||
|
|
||||||
|
|
||||||
# - name: Upload service script
|
- name: Upload service script config
|
||||||
# ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
# src: scripts/mqtt_srv.py
|
src: "{{ dest_folder }}/mqtt_srv.cfg"
|
||||||
# dest: /jffs/scripts/mqtt_srv/
|
dest: /etc/mqtt_srv/mqtt_srv.cfg
|
||||||
# mode: '755'
|
mode: '755'
|
||||||
# owner: admin
|
owner: root
|
||||||
# when: inventory_hostname in groups['router']
|
remote_src: true
|
||||||
# become: false
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Upload service script1
|
# - name: Upload service script1
|
||||||
ansible.builtin.copy:
|
# ansible.builtin.copy:
|
||||||
src: "{{ dest_folder }}/mqtt_srv.sh"
|
# src: scripts/mqtt_srv.sh
|
||||||
dest: /etc/init.d/
|
# dest: /jffs/scripts/mqtt_srv/
|
||||||
mode: '755'
|
# mode: '755'
|
||||||
owner: admin
|
# owner: admin
|
||||||
remote_src: true
|
# when: inventory_hostname in groups['router']
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
# become: false
|
||||||
|
|
||||||
- debug:
|
|
||||||
msg: "{{ dest_folder }}"
|
|
||||||
- name: Upload service script2
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ dest_folder }}/mqtt_srv.py"
|
|
||||||
dest: /usr/bin/mqtt_srv.py
|
|
||||||
mode: '755'
|
|
||||||
owner: admin
|
|
||||||
remote_src: true
|
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
|
||||||
|
|
||||||
- name: Install bottle python package
|
|
||||||
ansible.builtin.shell: pip install {{ item }} --break-system-packages
|
|
||||||
loop:
|
|
||||||
- paho-mqtt
|
|
||||||
- getmac
|
|
||||||
- ping3
|
|
||||||
- psutil
|
|
||||||
- autorandr
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
- name: Just force systemd to reread configs (2.4 and above)
|
|
||||||
ansible.builtin.systemd:
|
|
||||||
daemon_reload: true
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
|
# - name: Upload service script
|
||||||
|
# ansible.builtin.copy:
|
||||||
|
# src: scripts/mqtt_srv.py
|
||||||
|
# dest: /jffs/scripts/mqtt_srv/
|
||||||
|
# mode: '755'
|
||||||
|
# owner: admin
|
||||||
|
# when: inventory_hostname in groups['router']
|
||||||
|
# become: false
|
||||||
|
|
||||||
- name: Restart mqtt_srv service
|
# - name: Upload service script1
|
||||||
ansible.builtin.service:
|
# ansible.builtin.copy:
|
||||||
name: mqtt_srv.service
|
# src: "{{ dest_folder }}/mqtt_srv.sh"
|
||||||
state: restarted
|
# dest: /etc/init.d/
|
||||||
enabled: true
|
# mode: '755'
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
# owner: admin
|
||||||
|
# remote_src: true
|
||||||
|
# when: inventory_hostname == 'nas.home.lan'
|
||||||
|
|
||||||
- name: Restart mqtt service
|
- name: Print message
|
||||||
ansible.builtin.shell: "(/etc/init.d/mqtt_srv.sh restart >/dev/null 2>&1 &)"
|
ansible.builtin.debug:
|
||||||
async: 10
|
msg: "{{ dest_folder }}"
|
||||||
poll: 0
|
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
|
||||||
|
|
||||||
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
- name: Upload service script2
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ dest_folder }}/mqtt_srv.py"
|
||||||
|
dest: /myapps/mqtt_srv/mqtt_srv.py
|
||||||
|
mode: '755'
|
||||||
|
owner: admin
|
||||||
|
remote_src: true
|
||||||
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: Install venv
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- python3-virtualenv
|
||||||
|
|
||||||
|
- name: Install specified python requirements in indicated (virtualenv)
|
||||||
|
ansible.builtin.pip:
|
||||||
|
requirements: /myapps/mqtt_srv/requirements.txt
|
||||||
|
virtualenv: /myapps/mqtt_srv/venv
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: Just force systemd to reread configs (2.4 and above)
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: Restart mqtt_srv service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: mqtt_srv.service
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: Restart mqtt service
|
||||||
|
ansible.builtin.shell: "(/etc/init.d/mqtt_srv.sh restart >/dev/null 2>&1 &)"
|
||||||
|
async: 10
|
||||||
|
poll: 0
|
||||||
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
8
roles/omv_backup/files/omv_backup.service
Executable file
8
roles/omv_backup/files/omv_backup.service
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Enable OMV backup
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart = nohup /myapps/omv_backup.py -b > /dev/null 2>&1 &
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=basic.target
|
@ -1,69 +1,91 @@
|
|||||||
- block:
|
- name: Omv Setup
|
||||||
- name: include vault
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.include_vars:
|
block:
|
||||||
file: jaydee.yml
|
- name: Include vault
|
||||||
- name: Delete content & directory
|
ansible.builtin.include_vars:
|
||||||
ansible.builtin.file:
|
file: jaydee.yml
|
||||||
state: absent
|
name: mysecrets
|
||||||
path: "{{ dest_folder }}"
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
- name: GIT pull
|
- name: Delete content & directory
|
||||||
tags:
|
ansible.builtin.file:
|
||||||
- git_pull
|
state: absent
|
||||||
git:
|
path: "{{ dest_folder }}"
|
||||||
repo: "https://{{ git_user | urlencode }}:{{ git_password_mqtt | urlencode }}@gitlab.sectorq.eu/jaydee/omv_backup.git"
|
- name: Pull repo
|
||||||
dest: "{{ dest_folder }}"
|
tags:
|
||||||
update: yes
|
- git_pull
|
||||||
clone: yes
|
ansible.builtin.git:
|
||||||
version: main
|
repo: "https://{{ mysecrets['git_user'] | urlencode }}:{{ mysecrets['git_password_mqtt'] | urlencode }}@gitlab.sectorq.eu/jaydee/omv_backup.git"
|
||||||
- debug:
|
dest: "{{ dest_folder }}"
|
||||||
msg: "{{ inventory_hostname }}"
|
update: true
|
||||||
- name: Create a directory if it does not exist
|
clone: true
|
||||||
ansible.builtin.file:
|
version: main
|
||||||
path: /myapps
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
state: directory
|
- name: Print
|
||||||
mode: '0755'
|
ansible.builtin.debug:
|
||||||
owner: root
|
msg: "{{ inventory_hostname }}"
|
||||||
group: root
|
- name: Create a directory if it does not exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /myapps
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Upload script
|
- name: Upload script
|
||||||
ansible.builtin.copy:
|
ansible.builtin.copy:
|
||||||
src: "{{ dest_folder }}/omv_backup.py"
|
src: "{{ dest_folder }}/omv_backup.py"
|
||||||
dest: /myapps/omv_backup.py
|
dest: /myapps/omv_backup.py
|
||||||
remote_src: true
|
remote_src: true
|
||||||
mode: '0755'
|
mode: '0755'
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Upload requirements
|
|
||||||
ansible.builtin.copy:
|
|
||||||
src: "{{ dest_folder }}/requirements.txt"
|
|
||||||
dest: /myapps/requirements.txt
|
|
||||||
remote_src: true
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
- name: Install venv
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name:
|
|
||||||
- python3-virtualenv
|
|
||||||
|
|
||||||
- name: Install specified python requirements in indicated (virtualenv)
|
|
||||||
ansible.builtin.pip:
|
|
||||||
requirements: /myapps/requirements.txt
|
|
||||||
virtualenv: /myapps/venv
|
|
||||||
|
|
||||||
- name: 'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab'
|
|
||||||
ansible.builtin.cron:
|
|
||||||
name: "omv_backup"
|
|
||||||
state: absent
|
|
||||||
|
|
||||||
- name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null"
|
|
||||||
ansible.builtin.cron:
|
|
||||||
name: "omv_backup"
|
|
||||||
minute: "0"
|
|
||||||
hour: "8"
|
|
||||||
job: "/myapps/venv/bin/python3 /myapps/omv_backup.py -b > /dev/null 2>&1 &"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
become: true
|
- name: Upload requirements
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ dest_folder }}/requirements.txt"
|
||||||
|
dest: /myapps/requirements.txt
|
||||||
|
remote_src: true
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
|
- name: Install venv
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- python3-virtualenv
|
||||||
|
|
||||||
|
- name: Install specified python requirements in indicated (virtualenv)
|
||||||
|
ansible.builtin.pip:
|
||||||
|
requirements: /myapps/requirements.txt
|
||||||
|
virtualenv: /myapps/venv
|
||||||
|
|
||||||
|
- name: 'Ensure an old job is no longer present. Removes any job that is prefixed by "#Ansible: an old job" from the crontab'
|
||||||
|
ansible.builtin.cron:
|
||||||
|
name: "omv_backup"
|
||||||
|
state: absent
|
||||||
|
- name: Upload service config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: omv_backup.service
|
||||||
|
dest: /etc/systemd/system/omv_backup.service
|
||||||
|
mode: '0755'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: inventory_hostname == 'amd.home.lan'
|
||||||
|
- name: Restart omv service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: omv_backup
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
enabled: true
|
||||||
|
when: inventory_hostname == 'amd.home.lan'
|
||||||
|
# - name: Ensure a job that runs at 2 and 5 exists. Creates an entry like "0 5,2 * * ls -alh > /dev/null"
|
||||||
|
# ansible.builtin.cron:
|
||||||
|
# name: "omv_backup"
|
||||||
|
# minute: "0"
|
||||||
|
# hour: "8"
|
||||||
|
# job: "sudo /myapps/omv_backup.py -b > /dev/null 2>&1 &"
|
||||||
|
# state: present
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
- block:
|
- name: Setup policies
|
||||||
- name: Creating a file with content
|
|
||||||
copy:
|
|
||||||
dest: "/etc/polkit-1/rules.d/50_disable_pol.rules"
|
|
||||||
content: |
|
|
||||||
polkit.addRule(function(action, subject) {
|
|
||||||
if (action.id == "org.freedesktop.NetworkManager.wifi.scan") {
|
|
||||||
return polkit.Result.YES;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Creating a file with content
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/polkit-1/rules.d/50_disable_pol.rules"
|
||||||
|
content: |
|
||||||
|
polkit.addRule(function(action, subject) {
|
||||||
|
if (action.id == "org.freedesktop.NetworkManager.wifi.scan") {
|
||||||
|
return polkit.Result.YES;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
mode: '0644'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
76
roles/promtail/tasks/main.yml
Executable file
76
roles/promtail/tasks/main.yml
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
---
|
||||||
|
- name: Promtail
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Create dir
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/apt/keyrings/
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
- name: Create Banner
|
||||||
|
ansible.builtin.shell: wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor > /etc/apt/keyrings/grafana.gpg
|
||||||
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
# - name: < Fetch file that requires authentication.
|
||||||
|
# username/password only available since 2.8, in older versions you need to use url_username/url_password
|
||||||
|
# ansible.builtin.get_url:
|
||||||
|
# url: https://apt.grafana.com/gpg.key
|
||||||
|
# dest: /etc/foo.conf
|
||||||
|
# username: bar
|
||||||
|
# password: '{{ mysecret }}'
|
||||||
|
# changed_when: my_output.rc != 0
|
||||||
|
|
||||||
|
- name: Create Banner
|
||||||
|
ansible.builtin.shell: echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | tee /etc/apt/sources.list.d/grafana.list
|
||||||
|
register: my_output
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
|
- name: Install packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- promtail
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Creating a file with content
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: "/etc/promtail/config.yml"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: '0644'
|
||||||
|
content: |
|
||||||
|
# This minimal config scrape only single log file.
|
||||||
|
# Primarily used in rpm/deb packaging where promtail service can be started during system init process.
|
||||||
|
# And too much scraping during init process can overload the complete system.
|
||||||
|
# https://github.com/grafana/loki/issues/11398
|
||||||
|
|
||||||
|
server:
|
||||||
|
http_listen_port: 9080
|
||||||
|
grpc_listen_port: 0
|
||||||
|
|
||||||
|
positions:
|
||||||
|
filename: /tmp/positions.yaml
|
||||||
|
|
||||||
|
clients:
|
||||||
|
- url: http://192.168.77.101:3100/loki/api/v1/push
|
||||||
|
external_labels:
|
||||||
|
nodename: {{ inventory_hostname }}
|
||||||
|
|
||||||
|
scrape_configs:
|
||||||
|
- job_name: system
|
||||||
|
static_configs:
|
||||||
|
- targets:
|
||||||
|
- localhost
|
||||||
|
labels:
|
||||||
|
job: varlogs1
|
||||||
|
#NOTE: Need to be modified to scrape any additional logs of the system.
|
||||||
|
__path__: /var/log/zabbix/*.log
|
||||||
|
- targets:
|
||||||
|
- localhost
|
||||||
|
labels:
|
||||||
|
job: omv_backup
|
||||||
|
__path__: /myapps/omv_backup.log
|
||||||
|
|
||||||
|
- name: Sshd
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: promtail
|
||||||
|
state: restarted
|
@ -1,5 +1,5 @@
|
|||||||
---
|
# requirements.yml
|
||||||
collections:
|
collections:
|
||||||
- name: community.general
|
- name: community.general
|
||||||
source: https://galaxy.ansible.com
|
source: https://galaxy.ansible.com
|
||||||
|
- name: community.docker
|
||||||
|
5
roles/setup/tasks/main.yml
Executable file
5
roles/setup/tasks/main.yml
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
- name: Setup
|
||||||
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
||||||
|
block:
|
||||||
|
- name: Gather facts
|
||||||
|
ansible.builtin.setup:
|
@ -1,38 +1,40 @@
|
|||||||
- block:
|
- name: Set banner
|
||||||
- name: Install packages
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.apt:
|
block:
|
||||||
name:
|
- name: Install packages
|
||||||
- figlet
|
ansible.builtin.apt:
|
||||||
- toilet
|
name:
|
||||||
|
- figlet
|
||||||
|
- toilet
|
||||||
|
|
||||||
- name: Create Banner
|
- name: Create Banner
|
||||||
ansible.builtin.command: |
|
ansible.builtin.command: |
|
||||||
figlet -c {{ (inventory_hostname|split('.'))[0] }} -f slant
|
figlet -c {{ (inventory_hostname | split('.'))[0] }} -f slant
|
||||||
register: logo
|
register: logo
|
||||||
|
changed_when: "logo.rc == 0"
|
||||||
|
|
||||||
- name: Creating a file with content
|
- name: Creating a file with content
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
dest: "/etc/banner"
|
dest: "/etc/motd"
|
||||||
content: |
|
content: |
|
||||||
{{ logo.stdout }}
|
{{ logo.stdout }}
|
||||||
|
owner: 0
|
||||||
|
group: 0
|
||||||
|
mode: "0777"
|
||||||
|
|
||||||
- name: Reconfigure sshd
|
- name: Reconfigure sshd
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: "^Banner.* "
|
regexp: "^Banner.* "
|
||||||
line: "Banner /etc/banner"
|
line: "#Banner /etc/banner"
|
||||||
|
|
||||||
- name: Reconfigure sshd
|
- name: Reconfigure sshd
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: /etc/ssh/sshd_config
|
path: /etc/ssh/sshd_config
|
||||||
regexp: "^#PrintLastLog.* "
|
regexp: "^#PrintLastLog.* "
|
||||||
line: "PrintLastLog no"
|
line: "PrintLastLog no"
|
||||||
|
|
||||||
- name: sshd
|
- name: Sshd
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: ssh.service
|
name: ssh.service
|
||||||
state: restarted
|
state: restarted
|
||||||
become: true
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
24
roles/ssh_config/files/config
Executable file
24
roles/ssh_config/files/config
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
Host m-server
|
||||||
|
HostName m-server.home.lan
|
||||||
|
|
||||||
|
Host rpi5
|
||||||
|
HostName rpi5.home.lan
|
||||||
|
|
||||||
|
Host rack
|
||||||
|
HostName rack.home.lan
|
||||||
|
|
||||||
|
Host amd
|
||||||
|
HostName amd.home.lan
|
||||||
|
|
||||||
|
Host nas
|
||||||
|
HostName nas.home.lan
|
||||||
|
User admin
|
||||||
|
|
||||||
|
Host router
|
||||||
|
HostName router.home.lan
|
||||||
|
User root
|
||||||
|
|
||||||
|
Host *
|
||||||
|
User jd
|
||||||
|
IdentityFile ~/.ssh/id_rsa
|
||||||
|
StrictHostKeyChecking no
|
19
roles/ssh_config/tasks/main.yml
Executable file
19
roles/ssh_config/tasks/main.yml
Executable file
@ -0,0 +1,19 @@
|
|||||||
|
- name: SSH config Setup
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Upload config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: config
|
||||||
|
dest: /home/jd/.ssh/config
|
||||||
|
mode: '0600'
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
- name: Upload config
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: config
|
||||||
|
dest: /root/.ssh/config
|
||||||
|
mode: '0600'
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
1
roles/ssh_config/vars/main.yml
Executable file
1
roles/ssh_config/vars/main.yml
Executable file
@ -0,0 +1 @@
|
|||||||
|
dest_folder: "/tmp/ans_repo"
|
24
roles/ssh_keys/tasks/main.yml
Executable file
24
roles/ssh_keys/tasks/main.yml
Executable file
@ -0,0 +1,24 @@
|
|||||||
|
- name: SSH keys deploy
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Upload key
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: id_rsa
|
||||||
|
dest: /home/jd/.ssh/id_rsa
|
||||||
|
mode: '0600'
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
- name: Upload key
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: id_rsa
|
||||||
|
dest: /home/jd/.ssh/id_rsa.pub
|
||||||
|
mode: '0600'
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
- name: Set authorized key taken from file
|
||||||
|
ansible.posix.authorized_key:
|
||||||
|
user: jd
|
||||||
|
state: present
|
||||||
|
key: "{{ lookup('file', '/home/jd/.ssh/id_rsa.pub') }}"
|
14
roles/sshd_config/tasks/main.yml
Executable file
14
roles/sshd_config/tasks/main.yml
Executable file
@ -0,0 +1,14 @@
|
|||||||
|
- name: SSHD config Setup
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Reconfigure sshd
|
||||||
|
ansible.builtin.replace:
|
||||||
|
path: /etc/ssh/sshd_config
|
||||||
|
regexp: "^PermitRootLogin"
|
||||||
|
replace: "#PermitRootLogin"
|
||||||
|
- name: Restart ssh service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: ssh
|
||||||
|
state: restarted
|
||||||
|
daemon_reload: true
|
||||||
|
enabled: true
|
1
roles/sshd_config/vars/main.yml
Executable file
1
roles/sshd_config/vars/main.yml
Executable file
@ -0,0 +1 @@
|
|||||||
|
dest_folder: "/tmp/ans_repo"
|
12
roles/sudoers/tasks/main.yml
Executable file
12
roles/sudoers/tasks/main.yml
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
- name: Set sudoers
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
block:
|
||||||
|
- name: Allow the backup jd to sudo /myapps/omv_backup.py
|
||||||
|
community.general.sudoers:
|
||||||
|
name: allow-backup
|
||||||
|
state: present
|
||||||
|
user: jd
|
||||||
|
commands:
|
||||||
|
- /myapps/omv_backup.py *
|
||||||
|
- /usr/sbin/poweroff
|
||||||
|
- /usr/sbin/shutdown *
|
46
roles/vnc_server/tasks/main copy.yml
Executable file
46
roles/vnc_server/tasks/main copy.yml
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
- block:
|
||||||
|
|
||||||
|
- name: Install vnc packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- tigervnc-standalone-server
|
||||||
|
- tigervnc-common
|
||||||
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Create a directory if it does not exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /home/jd/.vnc/
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
- name: Creating a file with content
|
||||||
|
copy:
|
||||||
|
dest: "/home/jd/.vnc/config"
|
||||||
|
content: |
|
||||||
|
session=mate
|
||||||
|
geometry=1200x721
|
||||||
|
localhost
|
||||||
|
alwaysshared
|
||||||
|
mode: '0755'
|
||||||
|
owner: jd
|
||||||
|
group: jd
|
||||||
|
- name: Reconfigure vnc
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/tigervnc/vncserver-config-defaults
|
||||||
|
regexp: "^$localhost =.* "
|
||||||
|
line: '$localhost = "no";'
|
||||||
|
|
||||||
|
- name: Reconfigure vnc1
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: /etc/tigervnc/vncserver.users
|
||||||
|
#regexp: "^:1=.*"
|
||||||
|
line: ':1=jd'
|
||||||
|
|
||||||
|
- name: Reconfigure zabbix agent Server
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "/etc/tigervnc/vncserver.users"
|
||||||
|
regexp: "^:1=jd"
|
||||||
|
line: ":1=jd"
|
||||||
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
- block:
|
- block:
|
||||||
|
- name: include vault
|
||||||
|
ansible.builtin.include_vars:
|
||||||
|
file: jaydee.yml
|
||||||
- name: Install vnc packages
|
- name: Install vnc packages
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
name:
|
name:
|
||||||
@ -7,40 +9,45 @@
|
|||||||
- tigervnc-common
|
- tigervnc-common
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
|
||||||
|
- name: Creating config
|
||||||
|
become: true
|
||||||
|
ansible.builtin.copy:
|
||||||
|
|
||||||
|
dest: "/etc/systemd/system/vncserver@.service"
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Description=VNC Server
|
||||||
|
After=syslog.target network.target
|
||||||
|
[Service]
|
||||||
|
Type=forking
|
||||||
|
WorkingDirectory=/home/jd
|
||||||
|
User=jd
|
||||||
|
Group=jd
|
||||||
|
ExecStartPre=/bin/sh -c '/usr/bin/tigervncserver -kill %i > /dev/null 2>&1 || :'
|
||||||
|
ExecStart = /usr/bin/tigervncserver -xstartup /usr/bin/mate-session -SecurityTypes VncAuth,TLSVnc -geometry 1600x900 -localhost no %i
|
||||||
|
ExecStop = /usr/bin/tigervncserver -kill %i
|
||||||
|
Environment="HOME=/home/jd"
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
owner: root
|
||||||
|
mode: '0744'
|
||||||
- name: Create a directory if it does not exist
|
- name: Create a directory if it does not exist
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /home/jd/.vnc/
|
path: /home/jd/.vnc
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: '0700'
|
||||||
owner: jd
|
owner: jd
|
||||||
group: jd
|
group: jd
|
||||||
- name: Creating a file with content
|
- name: Set vnc password
|
||||||
copy:
|
ansible.builtin.shell:
|
||||||
dest: "/home/jd/.vnc/config"
|
cmd: echo "{{ vnc_password }}" | vncpasswd -f > /home/jd/.vnc/vncpasswd
|
||||||
content: |
|
- name: Set vnc password
|
||||||
session=mate
|
ansible.builtin.shell:
|
||||||
geometry=1200x721
|
cmd: echo "{{ vnc_password }}" | vncpasswd -f > /home/jd/.vnc/passwd
|
||||||
localhost
|
- name: Restart service vncserver, in all cases
|
||||||
alwaysshared
|
ansible.builtin.service:
|
||||||
mode: '0755'
|
name: vncserver@:1
|
||||||
owner: jd
|
state: restarted
|
||||||
group: jd
|
daemon-reload: true
|
||||||
- name: Reconfigure vnc
|
enabled: true
|
||||||
ansible.builtin.lineinfile:
|
become: true
|
||||||
path: /etc/tigervnc/vncserver-config-defaults
|
|
||||||
regexp: "^$localhost =.* "
|
|
||||||
line: '$localhost = "no";'
|
|
||||||
|
|
||||||
- name: Reconfigure vnc1
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: /etc/tigervnc/vncserver.users
|
|
||||||
#regexp: "^:1=.*"
|
|
||||||
line: ':1=jd'
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent Server
|
|
||||||
ansible.builtin.lineinfile:
|
|
||||||
path: "/etc/tigervnc/vncserver.users"
|
|
||||||
regexp: "^:1=jd"
|
|
||||||
line: ":1=jd"
|
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
|
||||||
|
|
@ -1,21 +1,29 @@
|
|||||||
- block:
|
- name: Setup loki agent
|
||||||
- name: Get keys
|
become: "{{ 'no' if inventory_hostname == 'nas.home.lan' else 'yes' }}"
|
||||||
ansible.builtin.shell: curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
|
block:
|
||||||
- name: Add repo
|
- name: Get keys
|
||||||
ansible.builtin.shell: echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
|
ansible.builtin.command: |
|
||||||
- name: Update cache
|
curl -s https://packages.wazuh.com/key/GPG-KEY-WAZUH | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/wazuh.gpg --import && chmod 644 /usr/share/keyrings/wazuh.gpg
|
||||||
ansible.builtin.apt:
|
changed_when: my_output.rc != 0
|
||||||
update_cache: true
|
|
||||||
- name: Instal wazuh
|
|
||||||
ansible.builtin.apt:
|
|
||||||
name: wazuh-agent
|
|
||||||
environment:
|
|
||||||
WAZUH_MANAGER: 'm-server.home.lan'
|
|
||||||
WAZUH_AGENT_NAME: "{{ inventory_hostname}}"
|
|
||||||
- name: Restart wazuh service
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: wazuh-agent
|
|
||||||
state: restarted
|
|
||||||
enabled: true
|
|
||||||
|
|
||||||
become: true
|
- name: Add repo
|
||||||
|
ansible.builtin.command: |
|
||||||
|
echo "deb [signed-by=/usr/share/keyrings/wazuh.gpg] https://packages.wazuh.com/4.x/apt/ stable main" | tee -a /etc/apt/sources.list.d/wazuh.list
|
||||||
|
changed_when: my_output.rc != 0
|
||||||
|
|
||||||
|
- name: Update cache
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
|
||||||
|
- name: Instal wazuh
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: wazuh-agent
|
||||||
|
environment:
|
||||||
|
WAZUH_MANAGER: 'm-server.home.lan'
|
||||||
|
WAZUH_AGENT_NAME: "{{ inventory_hostname }}"
|
||||||
|
|
||||||
|
- name: Restart wazuh service
|
||||||
|
ansible.builtin.service:
|
||||||
|
name: wazuh-agent
|
||||||
|
state: restarted
|
||||||
|
enabled: true
|
||||||
|
@ -1,175 +1,181 @@
|
|||||||
- block:
|
- name: Install zabbix agent
|
||||||
- name: Get config for not nas
|
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
ansible.builtin.set_fact:
|
block:
|
||||||
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
|
- name: Get config for not nas
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
ansible.builtin.set_fact:
|
||||||
|
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
|
||||||
- name: Get config for nas
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
ansible.builtin.set_fact:
|
|
||||||
zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf"
|
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
|
||||||
|
|
||||||
- name: Print all available facts
|
- name: Get config for nas
|
||||||
ansible.builtin.debug:
|
ansible.builtin.set_fact:
|
||||||
msg: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
zabbix_agent_cfg: "/opt/ZabbixAgent/etc/zabbix_agentd.conf"
|
||||||
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
|
|
||||||
- name: Print all available facts
|
- name: Print all available facts
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: ansible_facts.architecture
|
msg: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||||
- name: Print all available facts
|
|
||||||
ansible.builtin.debug:
|
|
||||||
var: ansible_distribution
|
|
||||||
- name: Print all available facts
|
|
||||||
ansible.builtin.debug:
|
|
||||||
var: ansible_distribution_major_version
|
|
||||||
# - name: Upload zabbix package
|
|
||||||
# ansible.builtin.copy:
|
|
||||||
# src: packages/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
|
||||||
# dest: /tmp/
|
|
||||||
- name: Install a .deb package from the internet11
|
|
||||||
ansible.builtin.apt:
|
|
||||||
deb: https://repo.zabbix.com/zabbix/6.4/ubuntu-arm64/pool/main/z/zabbix-release/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
|
||||||
when:
|
|
||||||
- ansible_facts.architecture != "armv7l" and ( ansible_distribution == "Ubuntu" or ansible_distribution == "Linux Mint" )
|
|
||||||
|
|
||||||
- name: Install a .deb package from the internet2
|
- name: Print all available facts
|
||||||
ansible.builtin.apt:
|
ansible.builtin.debug:
|
||||||
#deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
var: ansible_facts.architecture
|
||||||
deb: https://repo.zabbix.com/zabbix/7.0/raspbian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian11_all.deb
|
- name: Print all available facts
|
||||||
retries: 5
|
ansible.builtin.debug:
|
||||||
delay: 5
|
var: ansible_distribution
|
||||||
when:
|
- name: Print all available facts
|
||||||
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
|
ansible.builtin.debug:
|
||||||
|
var: ansible_distribution_major_version
|
||||||
|
# - name: Upload zabbix package
|
||||||
|
# ansible.builtin.copy:
|
||||||
|
# src: packages/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
||||||
|
# dest: /tmp/
|
||||||
|
- name: Install a .deb package from the internet111
|
||||||
|
ansible.builtin.apt:
|
||||||
|
deb: https://repo.zabbix.com/zabbix/7.2/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.2+ubuntu24.04_all.deb
|
||||||
|
when:
|
||||||
|
- ansible_facts.architecture != "armv7l" and ( ansible_distribution == "Ubuntu1" or ansible_distribution == "Linux Mint" )
|
||||||
|
|
||||||
ignore_errors: true
|
- name: Install a .deb package from the internet2
|
||||||
|
ansible.builtin.apt:
|
||||||
|
# deb: https://repo.zabbix.com/zabbix/6.4/raspbian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
||||||
|
deb: https://repo.zabbix.com/zabbix/7.2/release/raspbian/pool/main/z/zabbix-release/zabbix-release_latest_7.2+debian12_all.deb
|
||||||
|
retries: 5
|
||||||
|
delay: 5
|
||||||
|
when:
|
||||||
|
- ansible_facts.architecture == "armv7l" or ansible_facts.architecture == "aarch64"
|
||||||
|
register: command_result
|
||||||
|
failed_when: "'FAILED' in command_result.stderr"
|
||||||
|
|
||||||
- name: Install a .deb package from the internet3
|
- name: Install a .deb package from the internet3
|
||||||
ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian11_all.deb
|
||||||
|
when:
|
||||||
when:
|
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
|
||||||
- ansible_facts.architecture != "armv7l" and ansible_distribution == "Debian" and ansible_distribution_major_version == "11"
|
|
||||||
|
|
||||||
- name: Install a .deb package from the internet4
|
|
||||||
ansible.builtin.apt:
|
|
||||||
#deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
|
|
||||||
deb: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb
|
|
||||||
when:
|
|
||||||
- ansible_facts.architecture != "armv7l" and ansible_facts.architecture != "aarch64" and ansible_distribution == "Debian" and ansible_distribution_major_version == "12"
|
|
||||||
ignore_errors: true
|
|
||||||
|
|
||||||
# - name: Install a .deb package localy
|
- name: Install a .deb package from the internet4
|
||||||
# ansible.builtin.apt:
|
ansible.builtin.apt:
|
||||||
# deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
# deb: https://repo.zabbix.com/zabbix/6.4/debian/pool/main/z/zabbix-release/zabbix-release_6.4-1+debian12_all.deb
|
||||||
- name: Install zabbix packages
|
deb: https://repo.zabbix.com/zabbix/7.0/debian/pool/main/z/zabbix-release/zabbix-release_7.0-1+debian12_all.deb
|
||||||
ansible.builtin.apt:
|
when:
|
||||||
name:
|
- ansible_facts.architecture != "armv7l"
|
||||||
- zabbix-agent2
|
- ansible_facts.architecture != "aarch64"
|
||||||
- zabbix-agent2-plugin-mongodb
|
- ansible_distribution == "Debian"
|
||||||
- zabbix-agent2-plugin-postgresql
|
- ansible_distribution_major_version == "12"
|
||||||
# - zabbix-agent2-plugin-mysql
|
register: command_result
|
||||||
update_cache: yes
|
failed_when: "'FAILED' in command_result.stderr"
|
||||||
ignore_errors: true
|
# - name: Install a .deb package localy
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
# ansible.builtin.apt:
|
||||||
|
# deb: /tmp/zabbix-release_6.4-1+ubuntu22.04_all.deb
|
||||||
|
- name: Install zabbix packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- zabbix-agent2
|
||||||
|
- zabbix-agent2-plugin-mongodb
|
||||||
|
- zabbix-agent2-plugin-postgresql
|
||||||
|
# - zabbix-agent2-plugin-mysql
|
||||||
|
update_cache: true
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
- name: Install zabbix packages
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- zabbix-agent2
|
||||||
|
- zabbix-agent2-plugin-mongodb
|
||||||
|
- zabbix-agent2-plugin-postgresql
|
||||||
|
# - zabbix-agent2-plugin-mysql
|
||||||
|
only_upgrade: true
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent Server
|
- name: Reconfigure zabbix agent Server
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
regexp: "^Server=.*"
|
regexp: "^Server=.*"
|
||||||
insertafter: '^# Server='
|
insertafter: '^# Server='
|
||||||
line: "Server=192.168.77.0/24,172.30.0.0/24"
|
line: "Server=192.168.77.0/24,192.168.89.0/28"
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent ServerActive
|
- name: Reconfigure zabbix agent ServerActive
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
regexp: "^ServerActive=.*"
|
regexp: "^ServerActive=.*"
|
||||||
line: "ServerActive={{ ZABBIX_SERVER }}"
|
line: "ServerActive={{ ZABBIX_SERVER }}"
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix agent ListenPort
|
- name: Reconfigure zabbix agent ListenPort
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
regexp: "^ListenPort=.*"
|
regexp: "^ListenPort=.*"
|
||||||
line: "ListenPort=10050"
|
line: "ListenPort=10050"
|
||||||
# - name: Reconfigure zabbix agent ListenIP
|
# - name: Reconfigure zabbix agent ListenIP
|
||||||
# ansible.builtin.lineinfile:
|
# ansible.builtin.lineinfile:
|
||||||
# path: /"{{ zabbix_agent_cfg }}"
|
# path: /"{{ zabbix_agent_cfg }}"
|
||||||
# regexp: "^ListenIP=.*"
|
# regexp: "^ListenIP=.*"
|
||||||
# line: "ListenIP=0.0.0.0"
|
# line: "ListenIP=0.0.0.0"
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 hostname
|
- name: Reconfigure zabbix-agent2 hostname
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
regexp: "^Hostname=.*"
|
regexp: "^Hostname=.*"
|
||||||
line: "Hostname={{ inventory_hostname }}"
|
line: "Hostname={{ inventory_hostname }}"
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
insertafter: '^# UserParameter='
|
insertafter: '^# UserParameter='
|
||||||
regexp: "^UserParameter=system.certs.*"
|
regexp: "^UserParameter=system.certs.*"
|
||||||
line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py"
|
line: "UserParameter=system.certs,python3 /share/ZFS530_DATA/.qpkg/ZabbixAgent/cert_check2.py"
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
insertafter: '^# UserParameter='
|
insertafter: '^# UserParameter='
|
||||||
regexp: "^UserParameter=system.certs.*"
|
regexp: "^UserParameter=system.certs.*"
|
||||||
line: "UserParameter=system.certs,python3 /usr/bin/cert_check2.py"
|
line: "UserParameter=system.certs,python3 /usr/bin/cert_check2.py"
|
||||||
when: inventory_hostname == 'm-server.home.lan'
|
when: inventory_hostname == 'm-server.home.lan'
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 config
|
- name: Reconfigure zabbix-agent2 config
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
insertafter: '^# UserParameter='
|
insertafter: '^# UserParameter='
|
||||||
line: "UserParameter=rpi.hw.temp,/usr/bin/vcgencmd measure_temp"
|
line: "UserParameter=rpi.hw.temp,/usr/bin/vcgencmd measure_temp"
|
||||||
when: inventory_hostname == 'rpi5.home.lan'
|
when: inventory_hostname == 'rpi5.home.lan'
|
||||||
|
|
||||||
|
|
||||||
- name: Reconfigure zabbix-agent2 hostname
|
- name: Reconfigure zabbix-agent2 hostname
|
||||||
ansible.builtin.lineinfile:
|
ansible.builtin.lineinfile:
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
regexp: "^HostMetadata=.*"
|
regexp: "^HostMetadata=.*"
|
||||||
insertafter: '^# HostMetadata='
|
insertafter: '^# HostMetadata='
|
||||||
line: "HostMetadata=linux;jaydee"
|
line: "HostMetadata=linux;jaydee"
|
||||||
|
|
||||||
|
- name: Reconfigure zabbix-agent2 hostname
|
||||||
|
ansible.builtin.lineinfile:
|
||||||
|
path: "{{ zabbix_agent_cfg }}"
|
||||||
|
regexp: "^HostMetadata=.*"
|
||||||
|
insertafter: '^# HostMetadata='
|
||||||
|
line: "HostMetadata=server;jaydee"
|
||||||
|
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
||||||
|
|
||||||
|
- name: Add the user 'to group video
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: zabbix
|
||||||
|
groups: video
|
||||||
|
append: true
|
||||||
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
|
|
||||||
|
|
||||||
|
- name: Restart zabbix-agent2 service
|
||||||
- name: Reconfigure zabbix-agent2 hostname
|
ansible.builtin.service:
|
||||||
ansible.builtin.lineinfile:
|
name: zabbix-agent2.service
|
||||||
path: "{{ zabbix_agent_cfg }}"
|
state: restarted
|
||||||
regexp: "^HostMetadata=.*"
|
enabled: true
|
||||||
insertafter: '^# HostMetadata='
|
when: inventory_hostname != 'nas.home.lan'
|
||||||
line: "HostMetadata=server;jaydee"
|
|
||||||
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
|
- name: Restart agent
|
||||||
- name: Add the user 'to group video
|
ansible.builtin.command: /etc/init.d/ZabbixAgent.sh restart
|
||||||
ansible.builtin.user:
|
when: inventory_hostname == 'nas.home.lan'
|
||||||
name: zabbix
|
changed_when: false
|
||||||
groups: video
|
|
||||||
append: yes
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
- name: Restart zabbix-agent2 service
|
|
||||||
ansible.builtin.service:
|
|
||||||
name: zabbix-agent2.service
|
|
||||||
state: restarted
|
|
||||||
enabled: true
|
|
||||||
when: inventory_hostname != 'nas.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
- name: Restart agent
|
|
||||||
ansible.builtin.shell: /etc/init.d/ZabbixAgent.sh restart
|
|
||||||
when: inventory_hostname == 'nas.home.lan'
|
|
||||||
|
|
||||||
|
|
||||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
|
||||||
|
38
ssh_key.pem
Normal file
38
ssh_key.pem
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||||
|
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
|
||||||
|
NhAAAAAwEAAQAAAYEAoz4u+IAB09hgWyllpplK8864SkDd5p89w01p9NioW4FrOjES5U65
|
||||||
|
9ny6geIZKFRDmrdvcADidsbmOG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0k7tQc2nD44Ey9zme88/0sdHA2VIQ2
|
||||||
|
z/tlcPSQ8VKKhDmRY7BTE5YgeE6615nqvCq8e6CRSjFa0HKbfdFsmSnOHgil6Oc2MKT2pL
|
||||||
|
i/dKSxeAr2BP++xF9xYe0bVMdy4mEF8wAAAMEAuAsxC2bs0FnzoInge3W1ra55+qZF3LFp
|
||||||
|
efTVb26yciNYYeJLeks+nOjOQQd+kcISILdIhYnUGIumWQR/CiY2KL89AXLoTB6EIt5DGC
|
||||||
|
udKAjIzSeHtXTliZ1okgjGSmJeE6dhr0UwdLYyaFkdscbF17iTndLc74yCrKIoUnHfxBEc
|
||||||
|
/34AT8UdwkrJXj7e2nJyV9WGYz/Ga2xd3s56hVSTUckjxQaBnkZWFilw7ZAlHhPhSglTmd
|
||||||
|
pkgWv+Gd4evavBAAAAC2pkQG1vcmVmaW5lAQIDBAUGBw==
|
||||||
|
-----END OPENSSH PRIVATE KEY-----
|
Reference in New Issue
Block a user