Skip to content

Commit

Permalink
Fix resolvectl task returning white spaces
Browse files Browse the repository at this point in the history
Replace task command to fetch DNS sever from `resolvectl dns` command,
this will not return whitespaces.
Execute grep -m1 to limit the number of lines to 1.
Execute cut to return the first address.

Issue #410

Signed-off-by: Armando Neto <abiagion@redhat.com>
  • Loading branch information
netoarmando committed Jan 14, 2021
1 parent 307d6be commit f9fb4ca
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ansible/roles/machine/provision/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
when: ansible_distribution == 'Fedora' and ansible_distribution_version is version('32', '<=')

- name: get DNS server from resolvectl (fedora >= f33)
shell: "resolvectl status | grep 'Current DNS Server' | awk -F': ' '{print $2}'"
shell: "resolvectl dns | grep -m1 ': [1-9]' | awk -F': ' '{print $2}' | cut -d' ' -f 1"
register: dns_server_resolvectl
when: ansible_distribution == 'Fedora' and ansible_distribution_version is version('33', '>=')

Expand Down Expand Up @@ -102,7 +102,7 @@
- name: set hostname
shell: "hostnamectl set-hostname {{ inventory_hostname }}.ipa.test"

# Change selinux state if `selinux_enforcing: true` is set in test suite definition
# Change selinux state if `selinux_enforcing: true` is set in test suite definition
- name: set selinux to enforcing
selinux:
policy: targeted
Expand Down

0 comments on commit f9fb4ca

Please sign in to comment.