Skip to content

Commit

Permalink
Set REPO_CODENAME appropriately on all distros. (#105)
Browse files Browse the repository at this point in the history
Also:
* Remove Ubuntu 18.04 tests.
* Add Debian 11 tests.
* Add Ubuntu 22.04, Debian 12, RHEL/Rocky Linux 9 Ops Agent tests.
  • Loading branch information
igorpeshansky committed Aug 17, 2023
1 parent 5ad2f08 commit 99adb1e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 18 deletions.
14 changes: 7 additions & 7 deletions molecule/logging-test/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ platforms:
groups:
- linux
- rhel
- name: "ansible-ubuntu-1804-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-1804-lts
machine_type: e2-medium
size_gb: 40
groups:
- linux
- ubuntu
- name: "ansible-ubuntu-2004-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts
machine_type: e2-medium
Expand All @@ -65,6 +58,13 @@ platforms:
groups:
- linux
- debian
- name: "ansible-debian-11-${MOLECULE_SCENARIO_NAME}"
image_family: projects/debian-cloud/global/images/family/debian-11
machine_type: e2-medium
size_gb: 40
groups:
- linux
- debian
- name: "ansible-sles-12-${MOLECULE_SCENARIO_NAME}"
image_family: projects/suse-cloud/global/images/family/sles-12
machine_type: e2-medium
Expand Down
14 changes: 7 additions & 7 deletions molecule/monitoring-test/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ platforms:
groups:
- linux
- rhel
- name: "ansible-ubuntu-1804-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-1804-lts
machine_type: e2-medium
size_gb: 40
groups:
- linux
- ubuntu
- name: "ansible-ubuntu-2004-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts
machine_type: e2-medium
Expand All @@ -65,6 +58,13 @@ platforms:
groups:
- linux
- debian
- name: "ansible-debian-11-${MOLECULE_SCENARIO_NAME}"
image_family: projects/debian-cloud/global/images/family/debian-11
machine_type: e2-medium
size_gb: 40
groups:
- linux
- debian
- name: "ansible-sles-12-${MOLECULE_SCENARIO_NAME}"
image_family: projects/suse-cloud/global/images/family/sles-12
machine_type: e2-medium
Expand Down
34 changes: 31 additions & 3 deletions molecule/ops-agent-test/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ platforms:
groups:
- linux
- centos
- name: "ansible-rocky-9-${MOLECULE_SCENARIO_NAME}"
image_family: projects/rocky-linux-cloud/global/images/family/rocky-linux-9
machine_type: e2-medium
size_gb: 40
groups:
- linux
- centos
- name: "ansible-rhel-7-${MOLECULE_SCENARIO_NAME}"
image_family: projects/rhel-cloud/global/images/family/rhel-7
machine_type: e2-medium
Expand All @@ -44,27 +51,48 @@ platforms:
groups:
- linux
- rhel
- name: "ansible-ubuntu-1804-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-1804-lts
- name: "ansible-rhel-9-${MOLECULE_SCENARIO_NAME}"
image_family: projects/rhel-cloud/global/images/family/rhel-9
machine_type: e2-medium
size_gb: 40
groups:
- linux
- ubuntu
- rhel
- name: "ansible-ubuntu-2004-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-2004-lts
machine_type: e2-medium
size_gb: 40
groups:
- linux
- ubuntu
- name: "ansible-ubuntu-2204-${MOLECULE_SCENARIO_NAME}"
image_family: projects/ubuntu-os-cloud/global/images/family/ubuntu-2204-lts
machine_type: e2-medium
size_gb: 40
groups:
- linux
- ubuntu
- name: "ansible-debian-10-${MOLECULE_SCENARIO_NAME}"
image_family: projects/debian-cloud/global/images/family/debian-10
machine_type: e2-medium
size_gb: 40
groups:
- linux
- debian
- name: "ansible-debian-11-${MOLECULE_SCENARIO_NAME}"
image_family: projects/debian-cloud/global/images/family/debian-11
machine_type: e2-medium
size_gb: 40
groups:
- linux
- debian
- name: "ansible-debian-12-${MOLECULE_SCENARIO_NAME}"
image_family: projects/debian-cloud/global/images/family/debian-12
machine_type: e2-medium
size_gb: 40
groups:
- linux
- debian
- name: "ansible-sles-12-${MOLECULE_SCENARIO_NAME}"
image_family: projects/suse-cloud/global/images/family/sles-12
machine_type: e2-medium
Expand Down
30 changes: 29 additions & 1 deletion tasks/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,42 @@
check_mode: false
changed_when: false

- block:
- name: REPO_CODENAME on Debian/Ubuntu
set_fact:
repo_codename: "{{ ansible_distribution_release }}"
when: ansible_distribution in ['Debian', 'Ubuntu']

- name: REPO_CODENAME on RedHat/CentOS/Rocky
set_fact:
repo_codename: "el{{ ansible_distribution_major_version }}"
when: ansible_distribution in ['RedHat', 'CentOS', 'Rocky']

- name: REPO_CODENAME on Amazon
block:
- name: Monitoring agent
set_fact:
repo_codename: "amzn"
when: agent_type == 'monitoring'
- name: Logging agent
set_fact:
repo_codename: "el6"
when: agent_type == 'logging'
when: ansible_distribution == 'Amazon'

- name: REPO_CODENAME on SLES/openSUSE
set_fact:
repo_codename: "sles{{ ansible_distribution_major_version }}"
when: ansible_distribution in ['SLES', 'openSUSE', 'openSUSE Leap', 'SuSE', 'SLES_SAP']

- name: Add repo and install agent or remove repo and uninstall agent
command:
chdir: "{{ tempfolder.path }}"
cmd: >
bash add-{{ 'google-cloud-ops' if agent_type == 'ops-agent' else agent_type }}-agent-repo.sh {{ '--also-install' if package_state == 'present' else
'--uninstall --remove-repo' }} --version={{ version }} {{ '--dry-run' if ansible_check_mode else '' }}
environment:
REPO_CODENAME: "{{ ansible_distribution_release }}"
REPO_CODENAME: "{{ repo_codename | default(omit) }}"
register: result
retries: 5
delay: 10
Expand Down

0 comments on commit 99adb1e

Please sign in to comment.