Ajout Alma en cours

This commit is contained in:
stef
2026-02-17 23:01:51 +00:00
parent f3855df1a8
commit 7c8f30ce06
7 changed files with 114 additions and 99 deletions

View File

@@ -1,15 +1,31 @@
- name: Install RHEL packages
- name: Database - Install RHEL packages
ansible.builtin.dnf:
name: "{{ item }}"
state: latest
state: present
loop: "{{ db.packages }}"
tags:
- install_db
when: ansible_os_family == "RedHat"
- name: Enable and start service postgresl
- name: Database - Check if postgrsql configured
stat:
path: /var/lib/pgsql/data
register: postgresqldata
- name: Database - debug
debug:
var: postgresqldata
- name: Database - Init DB
ansible.builtin.shell:
cmd: postgresql-setup --initdb
when: postgresqldata.stat.exists == false
tags:
- install_db
- name: Database - Enable and start service postgresl
ansible.builtin.service:
name: postgresql
state: started
@@ -17,7 +33,7 @@
tags:
- install_db
- name: Generate create db script
- name: Database - Generate create db script
ansible.builtin.template:
src: create_db.j2
dest: /tmp/create_db.sql
@@ -25,26 +41,26 @@
tags:
- install_db
- name: Run create db script
- name: Database - Run create db script
ansible.builtin.shell: su - postgres -c 'psql -f /tmp/create_db.sql'
tags:
- install_db
- install_db
- name: Add zabbix user to pg_hba
- name: Database - Add zabbix user to pg_hba
ansible.builtin.lineinfile:
path: /etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf
insertafter: '# Database administrative login by Unix domain socket'
path: /var/lib/pgsql/data/pg_hba.conf
insertafter: '# "local" is for Unix domain socket connections only'
line: "local {{ db_name }} {{ db_user }} trust"
firstmatch: yes
state: present
- name: Find Group
- name: Database -Find Group
set_fact:
my_group: "{{ group_names | first }}"
- name: Créer les entrées pg_hba pour tous les hosts avec rôle 'srv'
- name: Database - Créer les entrées pg_hba pour tous les hosts avec rôle 'srv'
lineinfile:
path: /etc/postgresql/{{ postgresql_version }}/main/pg_hba.conf
path: /var/lib/pgsql/data/pg_hba.conf
line: "host {{ db_name }} {{ db_user }} {{ hostvars[item]['ansible_default_ipv4']['address'] }}/32 md5"
state: present
loop: "{{ groups[my_group] }}"
@@ -53,16 +69,16 @@
- hostvars[item].role == 'srv' or hostvars[item].role == 'front'
- hostvars[item]['ansible_default_ipv4'] is defined
- name: Configure postgres Listen address
- name: Database - Configure postgres Listen address
ansible.builtin.lineinfile:
path: /etc/postgresql/17/main/postgresql.conf
path: /var/lib/pgsql/data/postgresql.conf
regexp: '^#listen_addresses = .*'
line: "listen_addresses = '*'"
tags:
- install_db
- name: Restart postgresql
- name: Database - Restart postgresql
service:
name: postgresql
state: restarted

View File

@@ -0,0 +1,36 @@
- name: Front - Install packages
ansible.builtin.dnf:
name: "{{ item }}"
state: present
loop: "{{ front.packages }}"
tags:
- install_front
- name: Front - Configure nginx port
ansible.builtin.lineinfile:
path: /etc/nginx/conf.d/zabbix.conf
regexp: 'listen 8080;'
line: " listen 80;"
tags:
- install_front
notify: Restart nginx
- name: Front - Configure nginx url
ansible.builtin.lineinfile:
path: /etc/nginx/conf.d/zabbix.conf
regexp: 'server_name example.com;'
line: " server_name {{ inventory_hostname }};"
tags:
- install_front
notify:
- Restart nginx
- Restart php-fpm
- name: Front - Configure keepalived
ansible.builtin.template:
src: keepalived.conf.j2
dest: /etc/keepalived/keepalived.conf
owner: root
group: root
mode: 0644
notify: Restart Keepalived

View File

@@ -1,12 +1,10 @@
- name: Server - Install packages
ansible.builtin.dnf:
name: "{{ item }}"
state: latest
state: present
loop: "{{ srv.packages }}"
tags:
- install_srv
when: ansible_os_family == "RedHat"
- name: Server - Generate srv config
ansible.builtin.template:
src: zabbix_server.conf.j2
@@ -49,5 +47,6 @@
enabled: true
loop:
- zabbix-server
- zabbix-agent2
tags:
- install_srv