refactor ♻️: Improve Ansible expect module usage for samba-tool commands
Updated the community.general.expect and ansible.builtin.expect modules to use the correct Ansible modules, improving code readability and maintainability. This change ensures that the expected output is properly handled and reduces the risk of errors.
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
msg: "{{ addc_reverse_zone_name }} {{ addc_ansible_host }} {{ addc_admin_password }} {{ addc_ip_last_octet }} {{ addc_hostname }} {{ addc_auth_domain }}"
|
msg: "{{ addc_reverse_zone_name }} {{ addc_ansible_host }} {{ addc_admin_password }} {{ addc_ip_last_octet }} {{ addc_hostname }} {{ addc_auth_domain }}"
|
||||||
|
|
||||||
- name: "Create the reverse DNS zone {{ addc_reverse_zone_name }}"
|
- name: "Create the reverse DNS zone {{ addc_reverse_zone_name }}"
|
||||||
community.general.expect:
|
ansible.builtin.expect:
|
||||||
command: "samba-tool dns zonecreate {{ addc_ansible_host }} {{ addc_reverse_zone_name }} -U Administrator"
|
command: "samba-tool dns zonecreate {{ addc_ansible_host }} {{ addc_reverse_zone_name }} -U Administrator"
|
||||||
responses:
|
responses:
|
||||||
# Use the '(?i)' flag for case-insensitive matching of the prompt.
|
# Use the '(?i)' flag for case-insensitive matching of the prompt.
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
no_log: true # Highly recommended to prevent the password from appearing in logs
|
no_log: true # Highly recommended to prevent the password from appearing in logs
|
||||||
|
|
||||||
- name: "Create the PTR (reverse) DNS record"
|
- name: "Create the PTR (reverse) DNS record"
|
||||||
community.general.expect:
|
ansible.builtin.expect:
|
||||||
# Command syntax: samba-tool dns add <server> <zone> <record_name> PTR <target_fqdn>
|
# Command syntax: samba-tool dns add <server> <zone> <record_name> PTR <target_fqdn>
|
||||||
command: >
|
command: >
|
||||||
samba-tool dns add {{ addc_ansible_host }}
|
samba-tool dns add {{ addc_ansible_host }}
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
msg: 'Samba Shares found: {{ smbclient_output.stdout }}'
|
msg: 'Samba Shares found: {{ smbclient_output.stdout }}'
|
||||||
|
|
||||||
- name: "Verify Samba AD authentication by accessing the netlogon share"
|
- name: "Verify Samba AD authentication by accessing the netlogon share"
|
||||||
community.general.expect:
|
ansible.builtin.expect:
|
||||||
# Command to run: smbclient //localhost/netlogon -UAdministrator -c 'ls'
|
# Command to run: smbclient //localhost/netlogon -UAdministrator -c 'ls'
|
||||||
# The -c 'ls' command lists files on the share.
|
# The -c 'ls' command lists files on the share.
|
||||||
command: smbclient //localhost/netlogon -UAdministrator -c 'ls'
|
command: smbclient //localhost/netlogon -UAdministrator -c 'ls'
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
var: ptr_record_check.stdout
|
var: ptr_record_check.stdout
|
||||||
|
|
||||||
- name: "Verify Kerberos authentication using kinit"
|
- name: "Verify Kerberos authentication using kinit"
|
||||||
community.general.expect:
|
ansible.builtin.expect:
|
||||||
# Command to run: kinit administrator
|
# Command to run: kinit administrator
|
||||||
command: kinit administrator
|
command: kinit administrator
|
||||||
responses:
|
responses:
|
||||||
|
|||||||
Reference in New Issue
Block a user