fixed install playbook
This commit is contained in:
parent
67166656f3
commit
cf04997289
@ -6,83 +6,93 @@
|
||||
postgres_user: "{{ postgres_user }}"
|
||||
postgres_password: "{{ postgres_password }}"
|
||||
postgres_db: "{{ postgres_db }}"
|
||||
|
||||
|
||||
tasks:
|
||||
|
||||
|
||||
- name: Update zypper
|
||||
command: zypper refresh
|
||||
register: zypper_refresh
|
||||
changed_when: "'Refreshing' in zypper_refresh.stdout"
|
||||
|
||||
|
||||
- name: Update System
|
||||
zypper:
|
||||
name: '*'
|
||||
state: latest
|
||||
when: zypper_refresh.changed
|
||||
|
||||
|
||||
- name: Update PostgreSQL package
|
||||
zypper:
|
||||
name:
|
||||
- postgresql-server
|
||||
- postgresql-contrib
|
||||
state: present
|
||||
|
||||
|
||||
- name: PostgreSQL initdb
|
||||
command: sudo -u postgres initdb -D /var/lib/pgsql/data
|
||||
args:
|
||||
creates: /var/lib/pgsql/data/PG_VERSION
|
||||
|
||||
|
||||
- name: Systemctl start and enable PostgreSQL
|
||||
service:
|
||||
name: postgresql
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
|
||||
- name: python3-psycopg2 install
|
||||
zypper:
|
||||
name: python3-psycopg2
|
||||
state: present
|
||||
|
||||
|
||||
- name: Change listen_addresses in postgresql.conf
|
||||
lineinfile:
|
||||
path: /var/lib/pgsql/data/postgresql.conf
|
||||
regexp: '^#?listen_addresses\s*='
|
||||
line: "listen_addresses = '*'"
|
||||
notify: Restart PostgreSQL
|
||||
|
||||
|
||||
- name: Change pg_hba.conf
|
||||
lineinfile:
|
||||
path: /var/lib/pgsql/data/pg_hba.conf
|
||||
regexp: '^host\s+all\s+all\s+0\.0\.0\.0/0\s+md5'
|
||||
line: "host all all 0.0.0.0/0 md5"
|
||||
notify: Restart PostgreSQL
|
||||
|
||||
|
||||
- name: Create User PostgreSQL
|
||||
community.postgresql.postgresql_user:
|
||||
name: "{{ postgres_user }}"
|
||||
password: "{{ postgres_password }}"
|
||||
state: present
|
||||
|
||||
|
||||
- name: Create Base PostgreSQL
|
||||
community.postgresql.postgresql_db:
|
||||
name: "{{ postgres_db }}"
|
||||
owner: "{{ postgres_user }}"
|
||||
encoding: UTF8
|
||||
state: present
|
||||
|
||||
|
||||
|
||||
- name: Create a table for storing names and phone numbers
|
||||
community.postgresql.postgresql_query:
|
||||
db: "{{ postgres_db }}"
|
||||
query: >
|
||||
CREATE TABLE IF NOT EXISTS contacts (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name VARCHAR(100),
|
||||
phone_number VARCHAR(15)
|
||||
);
|
||||
login_user: "{{ postgres_user }}"
|
||||
login_password: "{{ postgres_password }}"
|
||||
|
||||
- name: Открыть порт PostgreSQL 5432 в файрволе
|
||||
command: firewall-cmd --add-port=5432/tcp --permanent
|
||||
become: yes
|
||||
|
||||
|
||||
|
||||
- name: Перезагрузить файрвол для применения изменений
|
||||
command: firewall-cmd --reload
|
||||
become: yes
|
||||
|
||||
|
||||
handlers:
|
||||
- name: Restart PostgreSQL
|
||||
service:
|
||||
name: postgresql
|
||||
state: restarted
|
||||
|
@ -2,14 +2,14 @@ pipeline {
|
||||
agent any
|
||||
|
||||
parameters {
|
||||
string(name: 'TARGET_IP', defaultValue: '192.168.0.72')
|
||||
string(name: 'DB_USER', defaultValue: 'myuser')
|
||||
string(name: 'DB_NAME', defaultValue: 'mydatabase')
|
||||
string(name: 'BACKUP_DIR', defaultValue: '/var/backups/postgresql')
|
||||
string(name: 'TARGET_IP', defaultValue: '192.168.0.72', description: 'IP адрес машины для установки PostgreSQL')
|
||||
string(name: 'DB_USER', defaultValue: 'myuser', description: 'Имя пользователя для базы данных PostgreSQL')
|
||||
string(name: 'DB_NAME', defaultValue: 'mydatabase', description: 'Имя базы данных PostgreSQL')
|
||||
string(name: 'BACKUP_DIR', defaultValue: '/var/backups/postgresql', description: 'Путь для сохранения резервных копий')
|
||||
}
|
||||
|
||||
environment {
|
||||
ANSIBLE_HOST_KEY_CHECKING = 'False'
|
||||
ANSIBLE_HOST_KEY_CHECKING = 'False'
|
||||
}
|
||||
|
||||
stages {
|
||||
|
Loading…
Reference in New Issue
Block a user