Skip to content

Commit ab71cf0

Browse files
authored
Use inventory vars to avoid dmidecode call to detect R4 instances (#330)
1 parent e95700e commit ab71cf0

1 file changed

Lines changed: 9 additions & 18 deletions

File tree

ansible/playbooks/tasks/detect-cloud-platform.yaml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,35 +18,26 @@
1818
register: probe_aws
1919
when: cloud_platform_name is undefined or cloud_platform_name | length == 0
2020

21-
- name: "Probe for AWS 1"
22-
become: true
23-
become_user: root
24-
ansible.builtin.command: dmidecode -s bios-version # | grep -iq "Amazon"
25-
changed_when: false
26-
failed_when: false
27-
register: probe_aws_1
28-
when: cloud_platform_name is undefined or cloud_platform_name | length == 0 or cloud_platform_name == "aws"
29-
30-
- name: Set AWS machine type fact
31-
ansible.builtin.set_fact:
32-
aws_machine_type_is_r4: true
33-
when:
34-
- cloud_platform_name is undefined or cloud_platform_name | length == 0 or cloud_platform_name == "aws"
35-
- probe_aws_1.stdout is match(".*amazon")
36-
3721
- name: Set AWS discovery fact
3822
ansible.builtin.set_fact:
3923
cloud_platform_is_aws: true
4024
when:
4125
- cloud_platform_name is undefined or cloud_platform_name | length == 0
4226
- probe_aws.rc == 0
43-
- probe_aws.stdout | lower == 'amazon ec2' or probe_aws_1.stdout is match(".*amazon")
27+
- probe_aws.stdout | lower == 'amazon ec2'
4428

45-
- name: Set AWS from var
29+
- name: Set AWS from var
4630
ansible.builtin.set_fact:
4731
cloud_platform_is_aws: true
4832
when: cloud_platform_name is defined and cloud_platform_name == "aws"
4933

34+
- name: Set AWS machine type fact for R4 instances
35+
ansible.builtin.set_fact:
36+
aws_machine_type_is_r4: true
37+
when:
38+
- cloud_platform_name is undefined or cloud_platform_name | length == 0 or cloud_platform_name == "aws"
39+
- hana_machinetype is match("r4.*")
40+
5041
# SEE: https://stackoverflow.com/questions/30911775/how-to-know-if-a-machine-is-an-google-compute-engine-instance
5142
- name: "Detect GCP"
5243
block:

0 commit comments

Comments
 (0)