Skip to content

Commit

Permalink
Update the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ozennou committed Dec 24, 2024
1 parent 499700f commit 783f7eb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
44 changes: 37 additions & 7 deletions .github/workflows/infra-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ on:
workflow_dispatch:

jobs:
CI:

permissions:
actions: read
contents: read
id-token: write
terraform:
env:
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
ARM_TENANT_ID: ${{ secrets.ARM_TENANT_ID }}
ARM_SUBSCRIPTION_ID: ${{ secrets.ARM_SUBSCRIPTION_ID }}
TF_VAR_ssh_pub_key_file: "./id_rsa.pub"
TF_VAR_admin_user: "ubuntu"
defaults:
run:
working-directory: ./infrastructure
Expand Down Expand Up @@ -73,4 +69,38 @@ jobs:
name: virtual machines ip address
path: ./infrastructure/virtual_machines.ini
retention-days: 1


ansible:
defaults:
run:
working-directory: ./configs
runs-on: ubuntu-latest
needs: terraform
steps:
- uses: actions/checkout@v4

- name: Setup SSH
run: |
echo ${{ secrets.SSH_PRIVATE_KEY}} > ./private_key.pem
chmod 600 ./private_key.pem
- name: Install ansible
run: |
sudo apt update > /dev/null 2>&1
sudo apt install ansible -y > /dev/null 2>&1
- name: Download virtual_machines.ini
uses: actions/download-artifact@v4
with:
name: virtual machines ip address
path: ./configs

- name: set the required environments
run: |
cat << EOF > .env
ROOT_PASSWD=${{ secrets.GITLAB_ROOT_PASSWD }}
RUNNER_REGISTRATION_TOKEN=${{ secrets.GITLAB_RUNNER_REGISTRATION_TOKEN }}
EOF
- name: test
run: ls -la
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
*.tfstate.*
.env
.env2
configs/gitlab.rb
configs/inventory.ini
configs/gitlab.rb
3 changes: 2 additions & 1 deletion configs/Gitlab-instance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
become: true

pre_tasks:
- name: Set SSH user for Ubuntu
- name: Set SSH user and private key file for Ubuntu
ansible.builtin.set_fact:
ansible_user: ubuntu
ansible_ssh_private_key_file: ./private_key.pem
when: ansible_os_family == "Debian"

tasks:
Expand Down
2 changes: 1 addition & 1 deletion configs/Gitlab-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
tasks:
- name: Copy .env file to remote server
ansible.builtin.copy:
src: "../.env" # Local path on your machine
src: "../.env"
dest: "/tmp/.env"

- name: Get env file content
Expand Down

0 comments on commit 783f7eb

Please sign in to comment.