-
Notifications
You must be signed in to change notification settings - Fork 10
Add safe initial synchronization support for new replication peers #14
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 all commits
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 |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| - name: Create temporary LDIF file for enabling outbound replication | ||
| ansible.builtin.copy: | ||
| dest: "/tmp/dirsrv_enable_replication.ldif" | ||
| content: | | ||
| dn: cn=agreement_with_{{ dirsrv_consumer_uri | urlsplit('hostname') | replace('.', '_') }},cn=replica,cn="{{ dirsrv_suffix }}",cn=mapping tree,cn=config | ||
| changetype: modify | ||
| replace: nsds5ReplicaEnabled | ||
| nsds5ReplicaEnabled: on | ||
| mode: '0600' | ||
| when: dirsrv_perform_initial_sync and dirsrv_enable_outbound_replication_after_sync | ||
|
|
||
| - name: Enable outbound replication after sync | ||
| ansible.builtin.command: > | ||
| ldapmodify | ||
| -x | ||
| {{ '-ZZ' if dirsrv_use_starttls else '' }} | ||
| -H {{ dirsrv_server_uri }} | ||
| -D "{{ dirsrv_rootdn }}" | ||
| -w "{{ dirsrv_rootdn_password }}" | ||
| -f /tmp/dirsrv_enable_replication.ldif | ||
| register: enable_result | ||
| changed_when: enable_result.rc == 0 | ||
| failed_when: enable_result.rc != 0 | ||
| when: dirsrv_perform_initial_sync and dirsrv_enable_outbound_replication_after_sync | ||
|
|
||
| - name: Remove temporary LDIF file for enabling replication | ||
| ansible.builtin.file: | ||
| path: "/tmp/dirsrv_enable_replication.ldif" | ||
| state: absent | ||
| when: dirsrv_perform_initial_sync and dirsrv_enable_outbound_replication_after_sync | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,3 +37,17 @@ | |
| - name: Supplier or master/both | ||
| ansible.builtin.include_tasks: configure_replication_agreement.yml | ||
| when: dirsrv_instance_is_supplier | ||
|
|
||
| - name: Perform initial sync if source server is specified | ||
| ansible.builtin.include_tasks: perform_initial_sync.yml | ||
| when: dirsrv_instance_is_supplier and dirsrv_initial_sync_source | length > 0 | ||
|
|
||
| - name: Enable outbound replication after initial sync | ||
| ansible.builtin.include_tasks: enable_outbound_replication.yml | ||
| when: dirsrv_instance_is_supplier and dirsrv_initial_sync_source | length > 0 and dirsrv_enable_outbound_replication_after_sync | ||
|
|
||
| - name: Restart service after replication agreement creation | ||
| ansible.builtin.include_tasks: restart_service.yml | ||
| when: | ||
| - dirsrv_instance_is_supplier or dirsrv_instance_is_consumer | ||
|
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. I'm not entirely sure, but isn't this going to restart the server even if the agreement is unchanged? If that's the case, is there any way to avoid it? |
||
| - dirsrv_initial_sync_source | length > 0 and dirsrv_enable_outbound_replication_after_sync | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| --- | ||
| - name: Check if initial sync is required | ||
| ansible.builtin.set_fact: | ||
| dirsrv_perform_initial_sync: "{{ dirsrv_initial_sync_source | length > 0 }}" | ||
|
|
||
| - name: Create temporary LDIF file for initiating sync | ||
| ansible.builtin.copy: | ||
| dest: "/tmp/dirsrv_initial_sync.ldif" | ||
| content: | | ||
| dn: cn=agreement_with_{{ ansible_hostname + "_" + ansible_domain | replace('.', '_') }},cn=replica,cn="{{ dirsrv_suffix }}",cn=mapping tree,cn=config | ||
| changetype: modify | ||
| add: nsds5BeginReplicaRefresh | ||
| nsds5BeginReplicaRefresh: start | ||
| mode: '0600' | ||
| delegate_to: "{{ dirsrv_initial_sync_source }}" | ||
| when: dirsrv_perform_initial_sync | ||
|
Comment on lines
+6
to
+16
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. Why a temporary file instead of |
||
|
|
||
| - name: Trigger initial sync from source server | ||
| ansible.builtin.command: > | ||
| ldapmodify | ||
| -x | ||
| {{ '-ZZ' if dirsrv_use_starttls else '' }} | ||
| -H {{ dirsrv_server_uri | regex_replace(ansible_fqdn, dirsrv_initial_sync_source) }} | ||
| -D "{{ dirsrv_rootdn }}" | ||
| -w "{{ dirsrv_rootdn_password }}" | ||
| -f /tmp/dirsrv_initial_sync.ldif | ||
| delegate_to: "{{ dirsrv_initial_sync_source }}" | ||
| register: sync_result | ||
| changed_when: sync_result.rc == 0 and "Replica is being initialized" not in (sync_result.stderr | default('')) | ||
| failed_when: sync_result.rc != 0 and "Replica is being initialized" not in (sync_result.stderr | default('')) | ||
| when: dirsrv_perform_initial_sync | ||
|
|
||
| - name: Remove temporary LDIF file | ||
| ansible.builtin.file: | ||
| path: "/tmp/dirsrv_initial_sync.ldif" | ||
| state: absent | ||
| delegate_to: "{{ dirsrv_initial_sync_source }}" | ||
| when: dirsrv_perform_initial_sync | ||
|
|
||
| - name: Wait for initial sync to complete | ||
| ansible.builtin.command: > | ||
| ldapsearch | ||
| -x | ||
| {{ '-ZZ' if dirsrv_use_starttls else '' }} | ||
| -H {{ dirsrv_server_uri | regex_replace(ansible_fqdn, dirsrv_initial_sync_source) }} | ||
| -D "{{ dirsrv_rootdn }}" | ||
| -w "{{ dirsrv_rootdn_password }}" | ||
| -b "cn=agreement_with_{{ ansible_hostname + "_" + ansible_domain | replace('.', '_') }},cn=replica,cn={{ dirsrv_suffix | replace('=', '\=') | replace(',', '\,') }},cn=mapping tree,cn=config" | ||
| nsds5replicaUpdateInProgress | ||
| register: sync_status | ||
| changed_when: false | ||
| until: "'nsds5replicaUpdateInProgress: FALSE' in (sync_status.stdout | default(''))" | ||
| retries: "{{ (dirsrv_initial_sync_timeout / 10) | int }}" | ||
| delay: 10 | ||
| delegate_to: "{{ dirsrv_initial_sync_source }}" | ||
| when: dirsrv_perform_initial_sync and dirsrv_wait_for_initial_sync | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| --- | ||
| - name: Restart local 389ds | ||
| ansible.builtin.service: | ||
| name: dirsrv@{{ dirsrv_serverid }} | ||
| state: restarted | ||
|
|
||
| - name: Restart remote consumer 389ds | ||
| ansible.builtin.service: | ||
| name: dirsrv@{{ dirsrv_serverid }} | ||
| state: restarted | ||
| delegate_to: "{{ dirsrv_consumer_uri | urlsplit('hostname') }}" |
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.
Why a temporary file instead of
community.general.ldap_attrs?