From 07a6319cb1486d29c27be8fa7e7e7d546a7028fe Mon Sep 17 00:00:00 2001 From: Jeremy Frasier Date: Mon, 17 Jun 2024 13:48:55 -0400 Subject: [PATCH] Prefer a dictionary to ternary logic The dictionary can handle more than two cases (should that ever be required) and is cleaner. --- vars/Amazon.yml | 10 +++++++++- vars/Debian.yml | 10 +++++++++- vars/RedHat.yml | 10 +++++++++- vars/Ubuntu.yml | 10 +++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/vars/Amazon.yml b/vars/Amazon.yml index 32a5dd4..8563b28 100644 --- a/vars/Amazon.yml +++ b/vars/Amazon.yml @@ -1,3 +1,11 @@ --- +# A dictionary whose keys are values of the Ansible fact +# ansible_architecture and whose values are processor architecture for +# which Nessus is to be installed, as specified in the Nessus package +# filename +architectures: + aarch64: arm64 + x86_64: amd64 + # The Amazon CloudWatch Agent URL -url: https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}/latest/amazon-cloudwatch-agent.rpm +url: https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/{{ architectures[ansible_architecture] }}/latest/amazon-cloudwatch-agent.rpm diff --git a/vars/Debian.yml b/vars/Debian.yml index b9a4dff..b53c372 100644 --- a/vars/Debian.yml +++ b/vars/Debian.yml @@ -1,3 +1,11 @@ --- +# A dictionary whose keys are values of the Ansible fact +# ansible_architecture and whose values are processor architecture for +# which Nessus is to be installed, as specified in the Nessus package +# filename +architectures: + aarch64: arm64 + x86_64: amd64 + # The Amazon CloudWatch Agent URL -url: https://s3.amazonaws.com/amazoncloudwatch-agent/debian/{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}/latest/amazon-cloudwatch-agent.deb +url: https://s3.amazonaws.com/amazoncloudwatch-agent/debian/{{ architectures[ansible_architecture] }}/latest/amazon-cloudwatch-agent.deb diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 4cf904c..3c255f4 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -1,3 +1,11 @@ --- +# A dictionary whose keys are values of the Ansible fact +# ansible_architecture and whose values are processor architecture for +# which Nessus is to be installed, as specified in the Nessus package +# filename +architectures: + aarch64: arm64 + x86_64: amd64 + # The Amazon CloudWatch Agent URL -url: https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}/latest/amazon-cloudwatch-agent.rpm +url: https://s3.amazonaws.com/amazoncloudwatch-agent/redhat/{{ architectures[ansible_architecture] }}/latest/amazon-cloudwatch-agent.rpm diff --git a/vars/Ubuntu.yml b/vars/Ubuntu.yml index 40c056d..1b2a657 100644 --- a/vars/Ubuntu.yml +++ b/vars/Ubuntu.yml @@ -1,3 +1,11 @@ --- +# A dictionary whose keys are values of the Ansible fact +# ansible_architecture and whose values are processor architecture for +# which Nessus is to be installed, as specified in the Nessus package +# filename +architectures: + aarch64: arm64 + x86_64: amd64 + # The Amazon CloudWatch Agent URL -url: https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/{{ 'amd64' if ansible_architecture == 'x86_64' else 'arm64' }}/latest/amazon-cloudwatch-agent.deb +url: https://s3.amazonaws.com/amazoncloudwatch-agent/ubuntu/{{ architectures[ansible_architecture] }}/latest/amazon-cloudwatch-agent.deb