From a51e126b420b962443630176f2a0fb5a554ef116 Mon Sep 17 00:00:00 2001 From: Kev Jimenez Date: Fri, 2 Feb 2024 03:15:35 +0000 Subject: [PATCH] added variables and github secrets test run --- .github/workflows/deploy.yml | 8 ++++++++ .gitignore | 1 - playbook.yml | 34 +++++++++++++++++++++++----------- terraform.tfvars | 6 ++++++ 4 files changed, 37 insertions(+), 12 deletions(-) create mode 100644 terraform.tfvars diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 4bf9265..c808721 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,4 +32,12 @@ jobs: - name: Run Ansible Playbook run: ansible-playbook -i aws_ec2.yml playbook.yml + + env: + DOCKER_USER: ${{ secrets.DOCKER_USER }} + DOCKER_KEY: ${{ secrets.DOCKER_KEY }} + CF_EMAIL: ${{ secrets.CF_EMAIL }} + CF_API: ${{ secrets.CF_API }} + ZONECF_ID: ${{ secrets.ZONECF_ID }} + PUB_KEY: ${{ secrets.PUB_KEY }} ... diff --git a/.gitignore b/.gitignore index 9abdd84..c6d6010 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ terraform.tfstate.backup -terraform.tfvars .terraform.lock.hcl .terraform/ .vscode/settings.json diff --git a/playbook.yml b/playbook.yml index 46417ce..df0e638 100644 --- a/playbook.yml +++ b/playbook.yml @@ -12,16 +12,6 @@ tasks: - - name: Install Apache - apt: - name: apache2 - state: present - - - name: Ensure apache is running - service: - name: apache2 - state: started - - name: Install Docker Prerequisites shell: | sudo apt-get install ca-certificates curl @@ -43,4 +33,26 @@ - containerd.io - docker-buildx-plugin - docker-compose-plugin -... + + - name: Log in to DockerHub + become_user: ubuntu + community.docker.docker_login: + username: {{ lookup('env', 'DOCKER_USER') }} + password: {{ lookup('env', 'DOCKER_KEY') }} + + - name: Install Docker Watchtower + community.docker.docker_container: + name: watchtower + image: containrrr/watchtower + volumes: + - /var/run/docker.sock:/var/run/docker.sock + - /home/ubuntu/.docker/config.json:/config.json + command: -i 15 --cleanup=true + + - name: Install Docker Static Web Portfolio + community.docker.docker_container: + name: kjstatic + image: kevjimenez/kjstatic + ports: + - 80:80 +... \ No newline at end of file diff --git a/terraform.tfvars b/terraform.tfvars new file mode 100644 index 0000000..abccf98 --- /dev/null +++ b/terraform.tfvars @@ -0,0 +1,6 @@ +#Secret Keys + +cf_api = \"{{ lookup('env', 'CF_API') }}\" +cf_email = \"{{ lookup('env', 'CF_EMAIL') }}\" +zonecf_id = \"{{ lookup('env', 'ZONECF_ID') }}\" +pub_key = \"{{ lookup('env', 'PUB_KEY') }}\" \ No newline at end of file