From a3b772c5434f591a895663eba06889026e8c9938 Mon Sep 17 00:00:00 2001 From: Sandwich Date: Mon, 28 Oct 2024 18:47:31 +0100 Subject: [PATCH] fix risky-shell-pipe --- roles/cleanup/tasks/main.yml | 2 +- roles/configuration/tasks/main.yml | 2 +- roles/environment/tasks/main.yml | 2 +- roles/virtualization/tasks/libvirt.yml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/roles/cleanup/tasks/main.yml b/roles/cleanup/tasks/main.yml index a187f37..fbd7b9d 100644 --- a/roles/cleanup/tasks/main.yml +++ b/roles/cleanup/tasks/main.yml @@ -52,7 +52,7 @@ state: absent - name: Get list of CD-ROM devices - ansible.builtin.shell: virsh --connect qemu:///system domblklist {{ hostname }} --details | grep 'cdrom' | awk '{print $3}' + ansible.builtin.shell: set -o pipefail && virsh --connect qemu:///system domblklist {{ hostname }} --details | grep 'cdrom' | awk '{print $3}' changed_when: false register: cdrom_devices diff --git a/roles/configuration/tasks/main.yml b/roles/configuration/tasks/main.yml index c0a8a76..e73a1a4 100644 --- a/roles/configuration/tasks/main.yml +++ b/roles/configuration/tasks/main.yml @@ -143,7 +143,7 @@ register: net_uuid - name: Retrieve Network Interface Name - ansible.builtin.shell: ip r | awk 'NR==1 {print $5}' + ansible.builtin.shell: set -o pipefail && ip r | awk 'NR==1 {print $5}' register: net_inf - name: Copy NetworkManager keyfile diff --git a/roles/environment/tasks/main.yml b/roles/environment/tasks/main.yml index cffe6ef..b6b9584 100644 --- a/roles/environment/tasks/main.yml +++ b/roles/environment/tasks/main.yml @@ -22,7 +22,7 @@ - name: Setect Interface when: hypervisor == "vmware" - ansible.builtin.shell: "ip l | awk -F': ' '!/lo/{print $2; exit}'" + ansible.builtin.shell: "set -o pipefail && ip l | awk -F': ' '!/lo/{print $2; exit}'" register: interface_name - name: Set IP-Address diff --git a/roles/virtualization/tasks/libvirt.yml b/roles/virtualization/tasks/libvirt.yml index 93415e6..267fab0 100644 --- a/roles/virtualization/tasks/libvirt.yml +++ b/roles/virtualization/tasks/libvirt.yml @@ -12,7 +12,7 @@ - name: Generate Random MAC Address delegate_to: localhost - ansible.builtin.shell: openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | sed 's/^/02:/' + ansible.builtin.shell: set -o pipefail && openssl rand -hex 5 | sed 's/\(..\)/\1:/g; s/.$//' | sed 's/^/02:/' changed_when: false register: mac_address_output