A Git Repsoitory#
In this milestone you will get ready to rebuild your application using Ansible and Terraform.
Labs#
In class we will get ready for the final version of our project.
Create a local GIT repository and push it to GitHub
Configure Ansible and use it to install packages on your new instance
Create a Git Repo#
In your devbox home directory create a new Git repository:
$ git config --global init.defaultBranch main
$ git config --global user.name "Your Name"
$ git config --global user.email "Your GitHub Email"
$ git init cis-91
That will create a CIS-91 directory. Do the next steps in that directory.
Ansible Setup#
Install Ansible and the necessary plugins:
$ sudo apt install pipx
$ pipx install --include-deps ansible
$ pipx inject ansible requests google-auth
$ source ~/.profile
Place this into a file called ~/.ansible.cfg:
[defaults]
host_key_checking = False
Place this YAML into a file called gcp.yaml:
plugin: gcp_compute
projects:
- your-project-here
auth_kind: machineaccount
keyed_groups:
- prefix: gcp
key: labels
- prefix: tags
key: tags
Test your inventory:
$ ansible-inventory --list -i gcp.yaml
$ ansible-inventory --graph -i gcp.yaml
If you see your box, proceed to the next step. Place this into a file called
playbook.yaml:
- hosts: all
name: Install Apache and PHP
become: yes
tasks:
- name: Install packages
ansible.builtin.apt:
update_cache: yes
cache_valid_time: 3600
name:
- apache2
- php
Execute your playbook with the command:
$ ansible-playbook -i gcp.yaml playbook.yaml
First Git Commit#
When you have Ansible working save your work by making a Git commit and pushing your repo up to GitHub.
Documentation#
Document your steps and post them to the class discussion form. Your post should include a link to your GitHub repository.