Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate Terraform 1.5.7 and add tool validation pipeline #208

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ansible.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Ansible

on: [push, pull_request]

jobs:
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/gluescript.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ name: Glue Script

on:
push:
branches:
- "main"
paths:
- scripts/qesap/**
- .github/workflows/gluescript.yml
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.3.6
terraform_version: 1.5.7
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform init
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/tools.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Tools environment

on:
push:
branches:
- "main"
paths:
- Dockerfile
- requirements.txt
- requirements.yml
- .github/workflows/tools.yml
pull_request:
paths:
- Dockerfile
- requirements.txt
- requirements.yml
- .github/workflows/tools.yml

env:
REGISTRY: ghcr.io

jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3

- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
push: false
load: true # Export to Docker Engine rather than pushing to a registry
tags: ${{ github.run_id }}
cache-from: type=gha
cache-to: type=gha,mode=max

- name: Test
run: |
cre=docker ./tools/image_test.sh ${{ github.run_id }}
15 changes: 11 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FROM opensuse/tumbleweed:latest
## AZURE
# way suggested on https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?pivots=zypper
RUN zypper ref && zypper up -y && \
zypper install -y tar gzip unzip curl python310-pip openssh && \
zypper install -y tar gzip unzip curl python311-pip openssh && \
rpm --import https://packages.microsoft.com/keys/microsoft.asc && \
zypper addrepo --name 'Azure CLI' --check https://packages.microsoft.com/yumrepos/azure-cli azure-cli && \
zypper install --from azure-cli -y azure-cli && \
Expand All @@ -21,13 +21,20 @@ RUN curl https://dl.google.com/dl/cloudsdk/channels/rapid/downloads/google-cloud
echo 'source ~/google-cloud-sdk/path.bash.inc' >> ~/.bashrc

## Terraform
RUN curl https://releases.hashicorp.com/terraform/1.3.6/terraform_1.3.6_linux_amd64.zip -o terraform.zip && \
RUN curl https://releases.hashicorp.com/terraform/1.5.7/terraform_1.5.7_linux_amd64.zip -o terraform.zip && \
unzip terraform.zip -d /usr/local/bin && \
terraform -install-autocomplete && \
rm terraform.zip

ENV VIRTUAL_ENV=/opt/venv
RUN python3.11 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip install --upgrade pip && \
pip install -r requirements.txt

COPY requirements.yml .
RUN ansible-galaxy install -r requirements.yml

RUN mkdir /src
WORKDIR /src
WORKDIR /src
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ This project is in a very early stage of development.

Tools needed

* Python 3.9
* terraform v1.3.6
* Python >= 3.9
* terraform v1.5.7
* ansible-core 2.13.5 : please refer to the **requirements.txt** file
* cloud provider cli tools (`az`, `aws`, `gcloud`)

Expand Down
25 changes: 25 additions & 0 deletions tools/image_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

img_name=$1
cre="${cre:-"podman"}"

#$cre build -f Dockerfile -t "${img_name}"

$cre run "${img_name}" terraform --version | grep 1.5.7 || ( echo "ERROR[$?] wrong or not usable Terraform" ; exit 1 )
$cre run -v $(pwd):/src "${img_name}" terraform -chdir=/src/terraform/azure init || ( echo "ERROR[$?] terraform init does not work for azure" ; exit 1 )
$cre run -v $(pwd):/src "${img_name}" terraform -chdir=/src/terraform/aws init || ( echo "ERROR[$?] terraform init does not work for aws" ; exit 1 )
$cre run -v $(pwd):/src "${img_name}" terraform -chdir=/src/terraform/gcp init || ( echo "ERROR[$?] terraform init does not work for google" ; exit 1 )

$cre run "${img_name}" python3.11 --version | grep 3.11 || ( echo "ERROR[$?] wrong or not usable Python" ; exit 1 )
$cre run "${img_name}" pip3.11 --version || ( echo "ERROR[$?] wrong or not usable pip" ; exit 1 )
$cre run "${img_name}" pip3.11 freeze | grep ansible-core || ( echo "ERROR[$?] ansible-core not installed" ; exit 1 )
$cre run "${img_name}" ansible --version || ( echo "ERROR[$?] wrong or not usable Terraform" ; exit 1 )
$cre run "${img_name}" ansible-galaxy --version || ( echo "ERROR[$?] wrong or not usable Terraform" ; exit 1 )

$cre run "${img_name}" pip3.11 freeze | grep aws || ( echo "ERROR[$?] aws cli not installed" ; exit 1 )
$cre run "${img_name}" aws --version || ( echo "ERROR[$?] wrong or not usable aws" ; exit 1 )
$cre run "${img_name}" az --version || ( echo "ERROR[$?] wrong or not usable az" ; exit 1 )
#$cre run "${img_name}" cat /root/.bashrc
# $cre run "${img_name}" gcloud --version


Loading