mirror of
https://gitlab.sectorq.eu/jaydee/ansible.git
synced 2025-12-14 01:54:56 +01:00
build
This commit is contained in:
@@ -149,6 +149,7 @@
|
||||
music --fstype=nfs,rw nas.home.lan:/music
|
||||
shows --fstype=nfs,rw nas.home.lan:/shows
|
||||
xxx --fstype=nfs,rw nas.home.lan:/xxx
|
||||
proxmox --fstype=nfs,rw nas.home.lan:/proxmox
|
||||
mode: '0600'
|
||||
owner: root
|
||||
group: root
|
||||
|
||||
@@ -13,7 +13,7 @@ IP=`ip route get 8.8.8.8 | head -1 | cut -d' ' -f7`
|
||||
fi
|
||||
HOST=`uname -n`
|
||||
openssl req -subj "/CN=$HOST" -sha256 -new -key server-key.pem -out server.csr
|
||||
echo subjectAltName = DNS:$HOST,IP:$IP,IP:127.0.0.1 >> extfile.cnf
|
||||
echo subjectAltName = DNS:$HOST,DNS:${HOST}.home.lan,IP:$IP,IP:127.0.0.1 >> extfile.cnf
|
||||
echo extendedKeyUsage = serverAuth >> extfile.cnf
|
||||
openssl x509 -req -days 365 -sha256 -in server.csr -CA ca.pem -CAkey ca-key.pem \
|
||||
-CAcreateserial -out server-cert.pem -extfile extfile.cnf -passin pass:"foobarpwd"
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- python3-virtualenv
|
||||
- rsync
|
||||
|
||||
- name: Install specified python requirements in indicated (virtualenv)
|
||||
ansible.builtin.pip:
|
||||
|
||||
@@ -1,39 +1,46 @@
|
||||
- name: Install ethtool
|
||||
ansible.builtin.apt:
|
||||
name: ethtool
|
||||
state: present
|
||||
become: true
|
||||
- name: Display all interfaces name
|
||||
ansible.builtin.debug:
|
||||
var: ansible_facts.interfaces
|
||||
- name: Get wifi adapter
|
||||
ansible.builtin.set_fact:
|
||||
active_adapter: '{{ item }}'
|
||||
loop: '{{ ansible_facts.interfaces }}'
|
||||
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
|
||||
- name: Install zabbix agent
|
||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||
block:
|
||||
- name: Include facts
|
||||
ansible.builtin.include_role:
|
||||
name: "setup"
|
||||
when: ansible_facts.architecture is not defined
|
||||
- name: Install ethtool
|
||||
ansible.builtin.apt:
|
||||
name: ethtool
|
||||
state: present
|
||||
become: true
|
||||
- name: Display all interfaces name
|
||||
ansible.builtin.debug:
|
||||
var: ansible_facts.interfaces
|
||||
- name: Get wifi adapter
|
||||
ansible.builtin.set_fact:
|
||||
active_adapter: '{{ item }}'
|
||||
loop: '{{ ansible_facts.interfaces }}'
|
||||
when: '(item.startswith("eno") or item.startswith("enp") or item.startswith("nic")) and not item.endswith("avahi")'
|
||||
|
||||
|
||||
- name: Creating config
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
dest: "/etc/systemd/system/wol@.service"
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Enable Wake On Lan
|
||||
- name: Creating config
|
||||
become: true
|
||||
ansible.builtin.copy:
|
||||
dest: "/etc/systemd/system/wol@.service"
|
||||
content: |
|
||||
[Unit]
|
||||
Description=Enable Wake On Lan
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart = /usr/sbin/ethtool --change %i wol g
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart = /usr/sbin/ethtool --change %i wol g
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
owner: root
|
||||
mode: '0744'
|
||||
- name: Restart service wol, in all cases
|
||||
ansible.builtin.service:
|
||||
name: wol@{{ item }}
|
||||
state: restarted
|
||||
enabled: true
|
||||
become: true
|
||||
loop: '{{ ansible_facts.interfaces }}'
|
||||
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
owner: root
|
||||
mode: '0744'
|
||||
- name: Restart service wol, in all cases
|
||||
ansible.builtin.service:
|
||||
name: wol@{{ item }}
|
||||
state: restarted
|
||||
enabled: true
|
||||
become: true
|
||||
loop: '{{ ansible_facts.interfaces }}'
|
||||
when: '(item.startswith("eno") or item.startswith("enp")) and not item.endswith("avahi")'
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
- name: Install zabbix agent
|
||||
become: "{{ false if inventory_hostname == 'nas.home.lan' else true }}"
|
||||
block:
|
||||
- name: Include facts
|
||||
ansible.builtin.include_role:
|
||||
name: "setup"
|
||||
when: ansible_facts.architecture is not defined
|
||||
|
||||
- name: Get config for not nas
|
||||
ansible.builtin.set_fact:
|
||||
zabbix_agent_cfg: "/etc/zabbix/zabbix_agent2.conf"
|
||||
@@ -55,6 +60,17 @@
|
||||
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.4/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.4+debian12_all.deb
|
||||
when:
|
||||
- ansible_facts.architecture != "armv7l"
|
||||
- ansible_facts.architecture != "aarch64"
|
||||
- ansible_distribution == "Debian"
|
||||
- ansible_distribution_major_version == "12"
|
||||
register: command_result
|
||||
failed_when: "'FAILED' in command_result.stderr"
|
||||
- name: Install a .deb package from the Debian 13
|
||||
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.4/release/debian/pool/main/z/zabbix-release/zabbix-release_latest_7.4+debian13_all.deb
|
||||
when:
|
||||
- ansible_facts.architecture != "armv7l"
|
||||
- ansible_facts.architecture != "aarch64"
|
||||
@@ -83,7 +99,7 @@
|
||||
- zabbix-agent2-plugin-postgresql
|
||||
# - zabbix-agent2-plugin-mysql
|
||||
only_upgrade: true
|
||||
state: latest
|
||||
state: present
|
||||
when: inventory_hostname != 'nas.home.lan'
|
||||
|
||||
- name: Reconfigure zabbix agent Server
|
||||
@@ -173,9 +189,40 @@
|
||||
regexp: "^HostMetadata=.*"
|
||||
insertafter: '^# HostMetadata='
|
||||
line: "HostMetadata=server;jaydee"
|
||||
when: inventory_hostname == 'nas.home.lan' or inventory_hostname == 'm-server.home.lan'
|
||||
when: inventory_hostname == 'm-server.home.lan'
|
||||
|
||||
- name: Add the user 'to group video
|
||||
- name: Create docker-swarm plugin directory
|
||||
ansible.builtin.file:
|
||||
path: /usr/lib/zabbix/plugins/docker-swarm/
|
||||
state: directory
|
||||
mode: '0755'
|
||||
owner: zabbix
|
||||
group: zabbix
|
||||
|
||||
- name: Copy docker-swarm plugin
|
||||
ansible.builtin.copy:
|
||||
src: docker-swarm-linux-amd64
|
||||
dest: /usr/lib/zabbix/plugins/docker-swarm/docker-swarm-linux-x86_64
|
||||
mode: '0755'
|
||||
owner: zabbix
|
||||
group: zabbix
|
||||
when: inventory_hostname == 'm-server.home.lan'
|
||||
|
||||
- name: Reconfigure zabbix-agent2 hostname
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
regexp: "^Plugins.DockerSwarm.System.Path=.*"
|
||||
insertafter: '^# HostMetadata='
|
||||
line: "Plugins.DockerSwarm.System.Path=/usr/lib/zabbix/plugins/docker-swarm/docker-swarm-linux-x86_64"
|
||||
when: inventory_hostname == 'm-server.home.lan'
|
||||
- name: Reconfigure zabbix-agent2 hostname
|
||||
ansible.builtin.lineinfile:
|
||||
path: "{{ zabbix_agent_cfg }}"
|
||||
regexp: "^Plugins.DockerSwarm.System.Timeout=.*"
|
||||
line: "Plugins.DockerSwarm.System.Timeout=30"
|
||||
when: inventory_hostname == 'm-server.home.lan'
|
||||
|
||||
- name: Add the user 'zabbix' to group video
|
||||
ansible.builtin.user:
|
||||
name: zabbix
|
||||
groups: video
|
||||
|
||||
Reference in New Issue
Block a user