-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow variables overwrite from group_vars/host_vars (#83)
The current implementation is loading variables from vars/ directory when the role is evaluated. Doing so prevent user to overwrite them in their group_vars/host_vars. A user can have several patroni clusters targeted by the same playbook, example: ```yaml - name: Configure PostgreSQL hosts: role_patroni_server any_errors_fatal: true become: true become_user: root roles: - kostiantyn-nemchenko.patroni ``` This PR follow the same implementation used by Jeff Geerling in each of its roles (kudos to him).
- Loading branch information
1 parent
2fceaeb
commit 72ee07a
Showing
7 changed files
with
95 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
--- | ||
- name: Include OS-specific variables | ||
include_vars: "{{ ansible_os_family }}.yml" | ||
tags: [patroni, patroni-install, patroni-configure] | ||
|
||
- name: Define Debian specific facts | ||
block: | ||
- name: Define postgresql_apt_key_url. | ||
set_fact: | ||
postgresql_apt_key_url: "{{ __postgresql_apt_key_url }}" | ||
when: postgresql_apt_key_url is not defined | ||
|
||
- name: Define postgresql_apt_repo. | ||
set_fact: | ||
postgresql_apt_repo: "{{ __postgresql_apt_repo }}" | ||
when: postgresql_apt_repo is not defined | ||
when: ansible_os_family == 'Debian' | ||
|
||
- name: Define RedHat specific facts | ||
block: | ||
- name: Define postgresql_yum_repo_url. | ||
set_fact: | ||
postgresql_yum_repo_url: "{{ __postgresql_yum_repo_url }}" | ||
when: postgresql_yum_repo_url is not defined | ||
|
||
- name: Define postgresql_yum_repo_pkg_name. | ||
set_fact: | ||
postgresql_yum_repo_pkg_name: "{{ __postgresql_yum_repo_pkg_name }}" | ||
when: postgresql_yum_repo_pkg_name is not defined | ||
|
||
- name: Define postgresql_yum_repo_pkg_version. | ||
set_fact: | ||
postgresql_yum_repo_pkg_version: "{{ __postgresql_yum_repo_pkg_version }}" | ||
when: postgresql_yum_repo_pkg_version is not defined | ||
when: | ||
- ansible_os_family == 'RedHat' | ||
- ansible_distribution != 'Fedora' | ||
|
||
- name: Define patroni_postgresql_packages. | ||
set_fact: | ||
patroni_postgresql_packages: "{{ __patroni_postgresql_packages | list }}" | ||
when: patroni_postgresql_packages is not defined | ||
|
||
- name: Define patroni_system_packages. | ||
set_fact: | ||
patroni_system_packages: "{{ __patroni_system_packages | list }}" | ||
when: patroni_system_packages is not defined | ||
|
||
- name: Define patroni_postgresql_data_dir. | ||
set_fact: | ||
patroni_postgresql_data_dir: "{{ __patroni_postgresql_data_dir }}" | ||
when: patroni_postgresql_data_dir is not defined | ||
|
||
- name: Define patroni_postgresql_config_dir. | ||
set_fact: | ||
patroni_postgresql_config_dir: "{{ __patroni_postgresql_config_dir }}" | ||
when: patroni_postgresql_config_dir is not defined | ||
|
||
- name: Define patroni_postgresql_bin_dir. | ||
set_fact: | ||
patroni_postgresql_bin_dir: "{{ __patroni_postgresql_bin_dir }}" | ||
when: patroni_postgresql_bin_dir is not defined | ||
|
||
- name: Define patroni_postgresql_pgpass. | ||
set_fact: | ||
patroni_postgresql_pgpass: "{{ __patroni_postgresql_pgpass }}" | ||
when: patroni_postgresql_pgpass is not defined | ||
|
||
- name: Define patroni_bin_dir. | ||
set_fact: | ||
patroni_bin_dir: "{{ __patroni_bin_dir }}" | ||
when: patroni_bin_dir is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
--- | ||
|
||
postgresql_apt_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" | ||
postgresql_apt_repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" | ||
__postgresql_apt_key_url: "https://www.postgresql.org/media/keys/ACCC4CF8.asc" | ||
__postgresql_apt_repo: "deb http://apt.postgresql.org/pub/repos/apt/ {{ ansible_distribution_release }}-pgdg main" | ||
|
||
patroni_postgresql_data_dir: "/var/lib/postgresql/{{ patroni_postgresql_version }}/{{ patroni_scope }}" | ||
patroni_postgresql_config_dir: "/var/lib/postgresql/{{ patroni_postgresql_version }}/{{ patroni_scope }}" | ||
patroni_postgresql_bin_dir: "/usr/lib/postgresql/{{ patroni_postgresql_version }}/bin" | ||
patroni_postgresql_pgpass: /var/lib/postgresql/.pgpass | ||
patroni_bin_dir: /usr/local/bin | ||
__patroni_postgresql_data_dir: "/var/lib/postgresql/{{ patroni_postgresql_version }}/{{ patroni_scope }}" | ||
__patroni_postgresql_config_dir: "/var/lib/postgresql/{{ patroni_postgresql_version }}/{{ patroni_scope }}" | ||
__patroni_postgresql_bin_dir: "/usr/lib/postgresql/{{ patroni_postgresql_version }}/bin" | ||
__patroni_postgresql_pgpass: /var/lib/postgresql/.pgpass | ||
__patroni_bin_dir: /usr/local/bin | ||
|
||
patroni_postgresql_packages: | ||
__patroni_postgresql_packages: | ||
- { name: "postgresql-{{ patroni_postgresql_version }}", state: "present" } | ||
- { name: "postgresql-client-{{ patroni_postgresql_version }}", state: "present" } | ||
- { name: "postgresql-contrib-{{ patroni_postgresql_version }}", state: "present" } | ||
- { name: "postgresql-server-dev-{{ patroni_postgresql_version }}", state: "present" } | ||
|
||
patroni_system_packages: | ||
__patroni_system_packages: | ||
- { name: "python3-psycopg2", state: "present" } | ||
- { name: "python3-pip", state: "present" } | ||
- { name: "jq", state: "present" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters