Skip to content

Commit

Permalink
Merge pull request #3416 from RachaelSTamakloe/ansible-os-test
Browse files Browse the repository at this point in the history
Adding integration test for ansible OS coverage
  • Loading branch information
RachaelSTamakloe authored Dec 18, 2024
2 parents 97b3e0f + 7d8061d commit 31195d0
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modules/scripts/startup-script/files/install_ansible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set -e
REQ_ANSIBLE_VERSION=2.11
REQ_ANSIBLE_PIP_VERSION=4.10.0
REQ_PIP_WHEEL_VERSION=0.37.1
Expand Down Expand Up @@ -197,13 +198,13 @@ main() {
fi

# upgrade wheel if necessary
wheel_pkg=$(${venv_python_path} -m pip list --format=freeze | grep "^wheel")
wheel_pkg=$(${venv_python_path} -m pip list --format=freeze | grep "^wheel" || true)
if [ "$wheel_pkg" != "wheel==${REQ_PIP_WHEEL_VERSION}" ]; then
${venv_python_path} -m pip install -U wheel==${REQ_PIP_WHEEL_VERSION}
fi

# upgrade setuptools if necessary
setuptools_pkg=$(${venv_python_path} -m pip list --format=freeze | grep "^setuptools")
setuptools_pkg=$(${venv_python_path} -m pip list --format=freeze | grep "^setuptools" || true)
if [ "$setuptools_pkg" != "setuptools==${REQ_PIP_SETUPTOOLS_VERSION}" ]; then
${venv_python_path} -m pip install -U setuptools==${REQ_PIP_SETUPTOOLS_VERSION}
fi
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
- name: Check if Ansible is installed
ansible.builtin.shell: |
command -v ansible >/dev/null 2>&1 && echo "Ansible is installed" || echo "Ansible is not installed"
register: ansible_check_result

- name: Assert Ansible is installed
ansible.builtin.assert:
that:
- ansible_check_result.stdout == "Ansible is installed"
115 changes: 115 additions & 0 deletions tools/cloud-build/daily-tests/blueprints/ansible-vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

blueprint_name: test-workstation-ansible

vars:
project_id: ## Set GCP Project ID Here ##
deployment_name: test-workstation-ansible
region: us-central1
zone: us-central1-a
machine_type: n2-standard-2
disk_type: pd-ssd
instance_count: 1

deployment_groups:
- group: primary
modules:

- id: network1
source: modules/network/pre-existing-vpc

- id: startup-script
source: modules/scripts/startup-script
settings:
install_ansible: true
runners:
- type: shell
destination: startup.sh
content: |
#!/bin/bash
set -ex
echo \$(ansible --version)
- id: workstation-centos
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: centos
add_deployment_name_before_prefix: true
instance_image:
name: centos-7-v20240611
project: centos-cloud

- id: workstation-ubuntu-2004
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: ubuntu2004
add_deployment_name_before_prefix: true
instance_image:
family: ubuntu-2004-lts
project: ubuntu-os-cloud

- id: workstation-ubuntu-2204
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: ubuntu2204
add_deployment_name_before_prefix: true
instance_image:
family: ubuntu-2204-lts
project: ubuntu-os-cloud

- id: workstation-debian
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: debian
instance_image:
family: debian-11
project: debian-cloud

- id: workstation-rocky-8
source: modules/compute/vm-instance
use:
- network1
- startup-script
settings:
name_prefix: rocky8
add_deployment_name_before_prefix: true
instance_image:
family: rocky-linux-8-optimized-gcp
project: rocky-linux-cloud

- id: wait-for-startup
source: community/modules/scripts/wait-for-startup
settings:
instance_names:
- $(workstation-centos.name[0])
- $(workstation-ubuntu-2004.name[0])
- $(workstation-ubuntu-2204.name[0])
- $(workstation-debian.name[0])
- $(workstation-rocky-8.name[0])
timeout: 7200
41 changes: 41 additions & 0 deletions tools/cloud-build/daily-tests/builds/ansible-vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
tags:
- m.pre-existing-vpc
- m.startup-script
- m.vm-instance
- m.wait-for-startup
- vm

timeout: 14400s # 4hr
steps:
- id: anisble-vm
name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/test-runner
entrypoint: /bin/bash
env:
- "ANSIBLE_HOST_KEY_CHECKING=false"
- "ANSIBLE_CONFIG=/workspace/tools/cloud-build/ansible.cfg"
args:
- -c
- |
set -x -e
cd /workspace && make
BUILD_ID_FULL=$BUILD_ID
BUILD_ID_SHORT=$${BUILD_ID_FULL:0:6}
ansible-playbook tools/cloud-build/daily-tests/ansible_playbooks/base-integration-test.yml \
--user=sa_106486320838376751393 --extra-vars="project=${PROJECT_ID} build=$${BUILD_ID_SHORT}" \
--extra-vars="@tools/cloud-build/daily-tests/tests/ansible-vm.yml"
25 changes: 25 additions & 0 deletions tools/cloud-build/daily-tests/tests/ansible-vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---

test_name: test-workstation-ansible
deployment_name: "ansible-vm-{{ build }}"
zone: us-central1-a
workspace: /workspace
blueprint_yaml: "{{ workspace }}/tools/cloud-build/daily-tests/blueprints/ansible-vm.yaml"
network: "default"
remote_node: "{{ deployment_name }}-centos-0"
post_deploy_tests:
- test-validation/test-ansible-vm.yml

0 comments on commit 31195d0

Please sign in to comment.