-
-
Notifications
You must be signed in to change notification settings - Fork 537
Drop delegate_to for SSH jump host compatibility #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
ccb2cea
7782035
bb2a604
e9c432f
ab85489
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -284,15 +284,15 @@ | |
| tags: haproxy, haproxy_service, load_balancing | ||
|
|
||
| - block: # for add_balancer.yml | ||
| - name: "Fetch haproxy.cfg file from {{ groups.balancers[0] }}" | ||
| - name: "Fetch haproxy.cfg file from {{ inventory_hostname }}" | ||
| run_once: true | ||
| ansible.builtin.fetch: | ||
| src: /etc/haproxy/haproxy.cfg | ||
| dest: "{{ files_dir | default(playbook_dir ~ '/files') }}/haproxy.cfg" | ||
| validate_checksum: true | ||
| flat: true | ||
| notify: "restart haproxy" | ||
| delegate_to: "{{ groups.balancers[0] }}" | ||
| when: "'balancers' in group_names" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is necessary to fetch files from the first node of the group. |
||
|
|
||
| - name: Copy haproxy.cfg file to replica | ||
| ansible.builtin.copy: | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -54,14 +54,14 @@ | |||||
| tags: keepalived_conf, keepalived | ||||||
|
|
||||||
| - block: # for add_balancer.yml | ||||||
| - name: "Fetch keepalived.conf conf file from {{ groups.balancers[0] }}" | ||||||
| - name: "Fetch keepalived.conf conf file from {{ inventory_hostname }}" | ||||||
| run_once: true | ||||||
| ansible.builtin.fetch: | ||||||
| src: /etc/keepalived/keepalived.conf | ||||||
| dest: "{{ files_dir | default(playbook_dir ~ '/files') }}/keepalived.conf" | ||||||
| validate_checksum: true | ||||||
| flat: true | ||||||
| delegate_to: "{{ groups.balancers[0] }}" | ||||||
| when: "'balancers' in group_names" | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also - first node in the group.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| - name: Copy keepalived.conf conf file to replica | ||||||
| ansible.builtin.copy: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -36,30 +36,32 @@ | |
| # The delegate_to parameter is used to execute the task on a different host than the one specified in the play's hosts parameter. | ||
| # In this case, the task is delegated to the first host in the pgbackrest group in the invetory. | ||
| - name: Get repo1-path value | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.set_fact: | ||
| repo1_path: "{{ pgbackrest_server_conf['global'] | selectattr('option', 'equalto', 'repo1-path') | map(attribute='value') | list | first }}" | ||
| when: pgbackrest_repo_type | lower == 'posix' | ||
| when: | ||
| - pgbackrest_repo_type | lower == 'posix' | ||
| - "'pgbackrest' in group_names" | ||
|
|
||
| - name: "Make sure the {{ repo1_path }} directory exists" | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.file: | ||
| path: "{{ repo1_path }}" | ||
| state: directory | ||
| owner: "{{ pgbackrest_repo_user }}" | ||
| group: "{{ pgbackrest_repo_user }}" | ||
| mode: "0750" | ||
| when: repo1_path | default('') | length > 0 | ||
| when: | ||
| - repo1_path | default('') | length > 0 | ||
| - "'pgbackrest' in group_names" | ||
|
|
||
| - name: Create stanza "{{ pgbackrest_stanza }}" | ||
| become: true | ||
| become_user: "{{ pgbackrest_repo_user }}" | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.command: "pgbackrest --stanza={{ pgbackrest_stanza }} --no-online stanza-create" | ||
| register: stanza_create_result | ||
| when: "'pgbackrest' in group_names" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this condition will not work because only the postgres_cluster group is declared in PLAY. - name: vitabaks.autobase.deploy_pgcluster | PostgreSQL Cluster Deployment
hosts: postgres_clusterIn this case, you need a separate PLAY for the pgbackest group. |
||
| changed_when: | ||
| - stanza_create_result.rc == 0 | ||
| - stanza_create_result.stdout is not search("already exists") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -165,7 +165,7 @@ | |||||
| loop_control: | ||||||
| index_var: idx | ||||||
| label: "{{ 'pgbouncer' if idx == 0 else 'pgbouncer-%d' % (idx + 1) }}" | ||||||
| delegate_to: "{{ groups.master[0] }}" | ||||||
| when: "'master' in group_names" | ||||||
|
|
||||||
| - name: Fetch userlist.txt conf file from master | ||||||
| run_once: true | ||||||
|
|
@@ -174,8 +174,9 @@ | |||||
| dest: "{{ files_dir | default(playbook_dir ~ '/files') }}/" | ||||||
| validate_checksum: true | ||||||
| flat: true | ||||||
| delegate_to: "{{ groups.master[0] }}" | ||||||
| when: not pgbouncer_auth_user|bool | ||||||
| when: | ||||||
| - not pgbouncer_auth_user|bool | ||||||
| - when: "'master' in group_names" | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bug :)
Suggested change
|
||||||
|
|
||||||
| - name: Copy pgbouncer.ini file to replica | ||||||
| ansible.builtin.copy: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,19 @@ | |
| - block: | ||
| - name: Gather facts from pgbackrest server | ||
| ansible.builtin.setup: | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| when: "'pgbackrest' in group_names" | ||
|
|
||
| - name: Update dnf cache | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.shell: dnf clean all && dnf -y makecache | ||
| args: | ||
| executable: /bin/bash | ||
| when: ansible_os_family == "RedHat" | ||
| when: | ||
| - ansible_os_family == "RedHat" | ||
| - "'pgbackrest' in group_names" | ||
|
|
||
| - name: Update apt cache | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.apt: | ||
| update_cache: true | ||
|
|
@@ -25,10 +25,11 @@ | |
| until: apt_status is success | ||
| delay: 5 | ||
| retries: 3 | ||
| when: ansible_os_family == "Debian" | ||
| when: | ||
| - ansible_os_family == "Debian" | ||
| - "'pgbackrest' in group_names" | ||
|
|
||
| - name: Install the latest version of pgbackrest package | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.package: | ||
| name: pgbackrest | ||
|
|
@@ -37,6 +38,7 @@ | |
| until: update_pgbackrest_package is success | ||
| delay: 5 | ||
| retries: 3 | ||
| when: "'pgbackrest' in group_names" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this condition will not work because only the "primary:secondary" groups is declared in PLAY. - name: "(1/4) PRE-UPDATE: Perform pre-update tasks"
hosts: "primary:secondary"In this case, you need a separate PLAY for the pgbackest group. |
||
| become: true | ||
| become_user: root | ||
| when: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -122,14 +122,13 @@ | |
| # pgBackRest (dedicated) | ||
| - block: | ||
| - name: pgbackrest | Check pg-path option | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.command: "grep -c '^pg[0-9]*-path=' {{ pgbackrest_conf_file | dirname }}/conf.d/{{ pgbackrest_stanza }}.conf" | ||
| register: pg_path_count | ||
| when: "'pgbackrest' in group_names" | ||
| changed_when: false | ||
|
|
||
| - name: pgbackrest | Update pg-path in pgbackrest.conf | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.replace: | ||
| path: "{{ pgbackrest_conf_file | dirname }}/conf.d/{{ pgbackrest_stanza }}.conf" | ||
|
|
@@ -139,13 +138,16 @@ | |
| loop_control: | ||
| index_var: idx | ||
| label: "pg{{ idx + 1 }}-path={{ pg_new_datadir }}" | ||
| when: pg_path_count.stdout | int > 0 | ||
| when: | ||
| - pg_path_count.stdout | int > 0 | ||
| - "'pgbackrest' in group_names" | ||
|
|
||
| - name: pgbackrest | Upgrade stanza "{{ pgbackrest_stanza }}" | ||
| delegate_to: "{{ groups['pgbackrest'][0] }}" | ||
| run_once: true | ||
| ansible.builtin.command: "pgbackrest --stanza={{ pgbackrest_stanza }} --no-online stanza-upgrade" | ||
| when: pg_path_count.stdout | int > 0 and pgbackrest_stanza_upgrade | bool | ||
| when: | ||
| - pg_path_count.stdout | int > 0 and pgbackrest_stanza_upgrade | bool | ||
| - "'pgbackrest' in group_names" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this condition will not work because only the "primary:secondary" groups is declared in PLAY. - name: "(6/6) POST-UPGRADE: Analyze a PostgreSQL database (update optimizer statistics) and Post-Upgrade tasks"
hosts: "primary:secondary"
...
- name: Running Post-Upgrade tasks
ansible.builtin.include_role:
name: vitabaks.autobase.upgrade
tasks_from: post_upgradeFor this reason, delegate_to was used. |
||
| become: true | ||
| become_user: "{{ pgbackrest_repo_user }}" | ||
| ignore_errors: true # show the error and continue the playbook execution | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, there will be an error because there will be a new haproxy node in the group that we are adding.
It is necessary to get files from the first node of the group.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if the first node in the group will be a new node?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is assumed that the user has read the documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it will work.