diff options
author | Paul B <paul+gh@bonaud.fr> | 2019-05-03 10:59:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 10:59:19 +0200 |
commit | c6719a82860c7855fb749f98734fe17c38c2fe78 (patch) | |
tree | 214db2306ef4a929da043d0209ca70bde78ee28b | |
parent | 0c83dd00b4110d55b1602ca8d732a8cb414cfd0a (diff) | |
parent | 29f3186f165565e03b3b091523f8b682be99404a (diff) | |
download | ansible-postgresql-role-c6719a82860c7855fb749f98734fe17c38c2fe78.tar.gz ansible-postgresql-role-c6719a82860c7855fb749f98734fe17c38c2fe78.tar.zst ansible-postgresql-role-c6719a82860c7855fb749f98734fe17c38c2fe78.zip |
Merge pull request #9 from chtitux/become-method
Allow to use any ansible become method
-rw-r--r-- | README.md | 3 | ||||
-rw-r--r-- | defaults/main.yml | 2 | ||||
-rw-r--r-- | tasks/postgres-common-postinstall.yml | 2 | ||||
-rw-r--r-- | tasks/postgres-database-extensions.yml | 2 | ||||
-rw-r--r-- | tasks/postgres-database.yml | 4 | ||||
-rw-r--r-- | tasks/postgres-user.yml | 4 |
6 files changed, 11 insertions, 6 deletions
@@ -75,6 +75,9 @@ postgres_allowed_hosts: | |||
75 | postgres_replication_hosts: | 75 | postgres_replication_hosts: |
76 | - user: replicator | 76 | - user: replicator |
77 | range: 10.0.0.0/24 | 77 | range: 10.0.0.0/24 |
78 | |||
79 | # Ansible related Configuration | ||
80 | postgres_become_method: su # Optional | ||
78 | ``` | 81 | ``` |
79 | 82 | ||
80 | #### Testing | 83 | #### Testing |
diff --git a/defaults/main.yml b/defaults/main.yml index 190ce5f..5876e94 100644 --- a/defaults/main.yml +++ b/defaults/main.yml | |||
@@ -7,6 +7,8 @@ postgres_clusters: [] | |||
7 | # postgres_pgbadger_server: ~ | 7 | # postgres_pgbadger_server: ~ |
8 | postgres_backup_enabled: false | 8 | postgres_backup_enabled: false |
9 | postgres_barman_rsync_enabled: false | 9 | postgres_barman_rsync_enabled: false |
10 | |||
11 | postgres_become_method: su | ||
10 | #------------------------------------------------------------# | 12 | #------------------------------------------------------------# |
11 | #------------ Postgresql Configuration defaults -------------# | 13 | #------------ Postgresql Configuration defaults -------------# |
12 | #- WARNING: defaults can change with major version upgrades -# | 14 | #- WARNING: defaults can change with major version upgrades -# |
diff --git a/tasks/postgres-common-postinstall.yml b/tasks/postgres-common-postinstall.yml index 715782c..9be3bde 100644 --- a/tasks/postgres-common-postinstall.yml +++ b/tasks/postgres-common-postinstall.yml | |||
@@ -7,7 +7,7 @@ | |||
7 | command: ssh-keygen -b 4096 -f /var/lib/postgresql/.ssh/id_rsa -N "" -q | 7 | command: ssh-keygen -b 4096 -f /var/lib/postgresql/.ssh/id_rsa -N "" -q |
8 | become: yes | 8 | become: yes |
9 | become_user: postgres | 9 | become_user: postgres |
10 | become_method: su | 10 | become_method: "{{ postgres_become_method }}" |
11 | args: | 11 | args: |
12 | creates: /var/lib/postgresql/.ssh/id_rsa | 12 | creates: /var/lib/postgresql/.ssh/id_rsa |
13 | 13 | ||
diff --git a/tasks/postgres-database-extensions.yml b/tasks/postgres-database-extensions.yml index edc4e8d..58585c0 100644 --- a/tasks/postgres-database-extensions.yml +++ b/tasks/postgres-database-extensions.yml | |||
@@ -13,7 +13,7 @@ | |||
13 | - name: "CREATE EXTENSION on database {{ postgres_dbname }}" | 13 | - name: "CREATE EXTENSION on database {{ postgres_dbname }}" |
14 | become: true | 14 | become: true |
15 | become_user: postgres | 15 | become_user: postgres |
16 | become_method: su | 16 | become_method: "{{ postgres_become_method }}" |
17 | postgresql_ext: | 17 | postgresql_ext: |
18 | name: "{{ postgres_extension_name }}" | 18 | name: "{{ postgres_extension_name }}" |
19 | db: "{{ postgres_dbname }}" | 19 | db: "{{ postgres_dbname }}" |
diff --git a/tasks/postgres-database.yml b/tasks/postgres-database.yml index c3537ea..0be2dff 100644 --- a/tasks/postgres-database.yml +++ b/tasks/postgres-database.yml | |||
@@ -1,7 +1,7 @@ | |||
1 | - name: Test if the PostgreSQL server is up | 1 | - name: Test if the PostgreSQL server is up |
2 | become: true | 2 | become: true |
3 | become_user: postgres | 3 | become_user: postgres |
4 | become_method: su | 4 | become_method: "{{ postgres_become_method }}" |
5 | command: psql --port={{ postgres_port }} --command='select NOW()' | 5 | command: psql --port={{ postgres_port }} --command='select NOW()' |
6 | register: postgres_up | 6 | register: postgres_up |
7 | ignore_errors: yes | 7 | ignore_errors: yes |
@@ -11,7 +11,7 @@ | |||
11 | - name: Create PostgreSQL database | 11 | - name: Create PostgreSQL database |
12 | become: true | 12 | become: true |
13 | become_user: postgres | 13 | become_user: postgres |
14 | become_method: su | 14 | become_method: "{{ postgres_become_method }}" |
15 | postgresql_db: | 15 | postgresql_db: |
16 | port: "{{ postgres_port }}" | 16 | port: "{{ postgres_port }}" |
17 | name: "{{ postgres_dbname }}" | 17 | name: "{{ postgres_dbname }}" |
diff --git a/tasks/postgres-user.yml b/tasks/postgres-user.yml index 308dab8..fcef9fc 100644 --- a/tasks/postgres-user.yml +++ b/tasks/postgres-user.yml | |||
@@ -1,7 +1,7 @@ | |||
1 | - name: Test if the PostgreSQL server is up | 1 | - name: Test if the PostgreSQL server is up |
2 | become: true | 2 | become: true |
3 | become_user: postgres | 3 | become_user: postgres |
4 | become_method: su | 4 | become_method: "{{ postgres_become_method }}" |
5 | command: psql --port={{ postgres_port }} --command='select NOW()' | 5 | command: psql --port={{ postgres_port }} --command='select NOW()' |
6 | register: postgres_up | 6 | register: postgres_up |
7 | ignore_errors: yes | 7 | ignore_errors: yes |
@@ -11,7 +11,7 @@ | |||
11 | - name: Create PostgreSQL user | 11 | - name: Create PostgreSQL user |
12 | become: true | 12 | become: true |
13 | become_user: postgres | 13 | become_user: postgres |
14 | become_method: su | 14 | become_method: "{{ postgres_become_method }}" |
15 | postgresql_user: | 15 | postgresql_user: |
16 | port: "{{ postgres_port }}" | 16 | port: "{{ postgres_port }}" |
17 | name: "{{ postgres_username }}" | 17 | name: "{{ postgres_username }}" |