update Jenkinsfile & backup playbook

This commit is contained in:
dima 2024-10-20 13:42:05 +03:00
parent e5f1ffb21d
commit bd630368ab
2 changed files with 6 additions and 4 deletions

6
Jenkinsfile vendored
View File

@ -1,14 +1,16 @@
pipeline { pipeline {
agent any agent any
environment { environment {
SSH_ROOT_PASSWORD = credentials('ssh_root_password') / SSH_ROOT_PASSWORD = credentials('ssh_root_password')
PSQL_PASSWORD = credentials('PSQL_pass') PSQL_PASSWORD = credentials('PSQL_pass')
ANSIBLE_HOST_KEY_CHECKING = 'False' ANSIBLE_HOST_KEY_CHECKING = 'False'
}
parameters { parameters {
string(name: 'DB_SERVER_IP', defaultValue: '192.168.0.71', description: 'IP-адрес сервера') string(name: 'DB_SERVER_IP', defaultValue: '192.168.0.71', description: 'IP-адрес сервера')
string(name: 'SSH_USER', defaultValue: 'root', description: 'Имя пользователя для SSH подключения') string(name: 'SSH_USER', defaultValue: 'root', description: 'Имя пользователя для SSH подключения')
string(name: 'DB_USER', defaultValue: 'postgres', description: 'Имя пользователя базы данных') string(name: 'DB_USER', defaultValue: 'postgres', description: 'Имя пользователя базы данных')
string(name: 'DB_NAME', defaultValue: 'mydb', description: 'Имя базы данных') string(name: 'DB_NAME', defaultValue: 'mydb', description: 'Имя базы данных')
string(name: 'BACKUP_DIR', defaultValue: '/var/backups/postgresql', description: 'Директория для бэкапа')
} }
stages { stages {
stage('Clone repository') { stage('Clone repository') {
@ -71,7 +73,7 @@ pipeline {
-e postgres_user=${params.DB_USER} \ -e postgres_user=${params.DB_USER} \
-e postgres_password=${PSQL_PASSWORD} \ -e postgres_password=${PSQL_PASSWORD} \
-e postgres_db=${params.DB_NAME} \ -e postgres_db=${params.DB_NAME} \
-e backup_dir=/path/to/backup -e backup_dir=${params.BACKUP_DIR}
""" """

View File

@ -4,7 +4,7 @@
become: true become: true
vars: vars:
backup_dir: "{{ backup_dir }}" backup_dir: "{{ backup_dir }}" #work
tasks: tasks:
- name: Create backup directory - name: Create backup directory