Skip to content
Snippets Groups Projects
Commit a2c8d59f authored by Nathan Fouere's avatar Nathan Fouere
Browse files

add first part

parent 15f24f45
No related merge requests found
- name: Deploy postgres
hosts: all
become: true
roles:
- pg_install
\ No newline at end of file
all:
hosts:
vm1:
ansible_host: 172.24.42.8
ansible_user: myusername
ansible_host: 10.129.178.113
ansible_user: root
ansible_port: 22
ansible_password: password
ansible_password: .16*U3w
- name: Install PostgreSQL repository
ansible.builtin.apt:
update_cache: yes
- name: Install postgresql
ansible.builtin.apt:
name: postgresql
state: present
- name: Install python3-psycopg2
ansible.builtin.apt:
name: python3-psycopg2
state: present
- name: Start and enable the service
ansible.builtin.service:
name: postgresql
state: started
enabled: yes
- name: "Create app database"
postgresql_db:
state: present
name: "bdd"
become_user: postgres
- name: "Create db user"
postgresql_user:
state: present
name: postgres
password: postgres
become_user: postgres
- name: "Grant db user access to app db"
postgresql_privs:
type: database
database: postgres
privs: all
roles: postgres
become_user: postgres
- name: "Allow md5 connection for the db user"
postgresql_pg_hba:
dest: "/etc/postgresql/16/main/pg_hba.conf"
contype: host
method: md5
address: all
become_user: postgres
- name: "Define Listen address"
postgresql_set:
name: listen_addresses
value: '0.0.0.0'
become_user: postgres
- name: "Restart Postgresql"
ansible.builtin.service:
name: postgresql
state: restarted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment