Activity 5: Lets create our own module and use it
- Refer Here for the changes done to reuse existing modules
Activity 6: Running Ansible from Terraform Provisioning
- To create this template i will be using AWS.
- To fetch the vpc id, we would be using a datasource. A data source in terraform can fetch the information
- Refer Here for the official docs of the vpc datasource
- Refer Here for the changes done to create an ec2 instance by fetching info from data sources
- Setup for Running Ansible from terraform provisioner

- Now create a ubuntu linux vm in the cloud of your choice
- Install aws cli Refer Here
sudo apt update
sudo apt install unzip -y
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- Now configure AWS CLI
aws configure - Install terraform on linux Refer Here
- Install Ansible on linux Refer Here
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y
ansible --version
- Ensure all the necessary softwares are installed as mentioned above to check refer the below image

- Refer Here for the changes done with playbook and ensure python3 is installed on new node created
- Refer Here for the ansible playbook execution command added to provisioner

- Refer Here for the terraform template which calls ansible playbook
