diff --git a/.github/actions/get-host-info/action.yml b/.github/actions/get-host-info/action.yml new file mode 100644 index 0000000..372de3c --- /dev/null +++ b/.github/actions/get-host-info/action.yml @@ -0,0 +1,30 @@ +name: Setup K8S Environment +description: Prepare the environment for A13labs CI/CD pipelines +inputs: + vault-master-password: + description: "The master password for the vault" + required: true + ansible-user: + description: "The user to use for Ansible" + required: true + target-host: + description: "The target host to read the system ID" + default: "microk8s" +outputs: + system_id: + description: "The system ID of the target host" + value: ${{ steps.get-system-id.outputs.stdout }} + +runs: + using: "composite" + steps: + - name: Get System ID + id: get-system-id + shell: bash + env: + VAULT_MASTER_PASSWORD: ${{ inputs.vault-master-password }} + ANSIBLE_USER: ${{ inputs.ansible-user }} + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + TARGET_HOST: ${{ inputs.target-host }} + run: | + ansible -i ansible/inventory/hosts -b -u $ANSIBLE_USER -m shell -a "read_system_id" $TARGET_HOST | tail -1 diff --git a/.github/workflows/actions-validate.yml b/.github/workflows/actions-validate.yml index b805e43..3d85089 100644 --- a/.github/workflows/actions-validate.yml +++ b/.github/workflows/actions-validate.yml @@ -9,50 +9,7 @@ on: - .github/workflows/actions-*.yml jobs: - test-setup-ansible-actions: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup environment - uses: ./.github/actions/setup-env - - - name: Setup Ansible environment - uses: ./.github/actions/setup-ansible-env - with: - vault-master-password: ${{ secrets.VAULT_MASTER_PASSWORD }} - ansible-user: ${{ secrets.ANSIBLE_USER }} - trusted-hosts: ${{ secrets.TRUSTED_HOSTS }} - - - name: Test ansible - run: | - ansible --version - - test-setup-terraform-actions: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup environment - uses: ./.github/actions/setup-env - - - name: Setup Terraform - uses: hashicorp/setup-terraform@v1 - with: - terraform_version: 1.9.6 - - - name: Test terraform - run: | - terraform --version - - test-setup-terraforms-k8s-actions: + test-cicd-actions: runs-on: ubuntu-latest steps: @@ -82,6 +39,13 @@ jobs: vault-master-password: ${{ secrets.VAULT_MASTER_PASSWORD }} ansible-user: ${{ secrets.ANSIBLE_USER }} + - name: Get Host Info + uses: ./.github/actions/get-host-info + id: get-host-info + with: + vault-master-password: ${{ secrets.VAULT_MASTER_PASSWORD }} + ansible-user: ${{ secrets.ANSIBLE_USER }} + - name: Test ansible run: | ansible --version