research
devops
provisioning
aws
ansible
terraform
Hello @everyone, how is this going ? Today, on this blog i happily for exprience with AWS cloud and work with it, So go check and provisioning with me about Terraform, Ansible and AWS
Ansible
, Is it the same as like Terraform
or not ? That will be many type of questions about that. So with me Ansible, like IaC tools - "absolutely sure" but that more kind than this, with Ansible
you can do setup one or more machine in onetime remotely just with your code, If compare with Terraform
that will not equivalent because it do such different, so how is that it different, Go to more detail in below. Suppercool AWS
is incredible thing which everyone in this industry will and should learn about that. AWS
is the one of biggest platforms about Cloud, AWS
is the best way for you service like secure, fastly, safety, easily to use, β¦WSL or Linux Environmnement for Running (Ansible Compile Error in Windows Machine)
Machine need python3
and pip3
installed before installing Ansible
tools
Install Ansible
for your machine to running the process referenced with Ansible
. Just with pip3 install ansible ansible-lint
Install aws-cli
for purpose connect your ansible with AWS Cloud via this secret things
ββββββ #!/bin/bash
ββββββ curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
ββββββ unzip awscliv2.zip
ββββββ sudo ./aws/install
Feel free your requirements when installing ansible pluggin via ansible-galaxy
, that will be provided you many pluggins for multiple purpose of provisioning and managing cloud resources by ansible.
You need to having AWS account - Free tier for example. With free-tier, you just need to have credit or debit card with 1$ to verify and you will have it. Go check detail about the free tier on this link
Optionally, you can configure some extensions for easily working with ansible on VSCode - IDK another have include or not !
redhat.ansible
β> That things for detection with you what pluggin work withansible-lint
β> You can also download ansible-lint
by pip3 install ansible-lint
If you complete the list of work above, you are ready to go this step. Free free and try
Learn More β
Fistly, you need to calm mind for doing this job. Because it will not protected your account, but also that easily step for doing such thing with AWS. But have more way you can verify that. Find more than in these link:
Secondly, the topic is not diggest inside the aws cloud, but you need to remmembering about doing not to expose your credentials to another. That is not secure for your account - remmember that. Try the best way for suitable with your situation.
aws-cli
or ansible
with your AWS, the after step is more easily, you just need write a code and applied that.playbook
: This is the file which you put the step of your job and task inside for doing that for local
or remote
machineinventory
: This is folder which you can put your hosts
file inside , which your define what IP address of remote PC need to be configuration (IDK to much about right construct of Ansible Project ansible.cfg
: This is file which you give a configuration for your ansible, this will help you ignore something annoy warning, accesslist import modules, β¦ Give a short time to take at thisinclude both Ansible and Terraform for working with. Ansible will responsibility for doing the configuration and interact with Terraform inside Runner - Make a runner for ansible in AWS
Ansible
have role like 3th party tools, it will do twice job:
ansible-runner
in AWS Cloud
and you can connect it directly with Authentication SSH Key
. Ideally, When you doing that job you will control and plan for setting up your pipeline CI/CD
easier than do it with Terraform.provisioning
infrastructure with AWS providerAnsible:
Ansible will have options create - destroy runner, that is median thing will connect you and aws cloud, so go through and check it
ββββββ Command: ansible-playbook <which_ansible_file_you_want> \
ββββββ --tags <which_tag_you_want_to_choice>
ββββββ Tags (Just need only for create Runner):
ββββββ 1. create-ssh-key: Create ssh key with name default or pass for it
ββββββ 2. create-runner: Create Ansible-Runner in cloud using the t2.micro image
ββββββ 3. view-runner: View and upgrade host for run teraform inside that
terraform-runner-folder will have options for you install and copy content for terraform and run terraform flow to working with
ββββββ command: ansible-playbook terraform.yaml --extra-vars <key>=<value> --tags <which_tag_you_want_to_choice>
ββββββ Tags:
ββββββ 1. install-terraform: For install terraform tool for Ansible-Runner
ββββββ 2. copy_content: Copy content from local terraform into remove with sync configuration
ββββββ 3. terraform_init_plan: Init and view plan state of terraform before applied (Need --extra-vars)
ββββββ 4. terraform_apply: applied what terraform plan return (Need --extra-vars)
ββββββ 5. terraform_display_destroy: Init and view plan state of destroy process will be occured after destruction (Need --extra-vars)
ββββββ 6. terraform_destroy: Destroy process with destroy plan (Need --extra-vars)
Terraform (This is include in Ansible - Try that for manual if you just only want to use individually):
So with terraform be come easily to run, just go to right env and applied terraform work flow
With create or update for your infrastructure
ββββββ 1. terraform init or terraform init --reconfigure (if you want to make sure with new configure which new update like upgrade provider version, ...)
ββββββ 2. terraform plan
ββββββ 3. terraform apply -auto-approve
With destroy for your infrastructure
ββββββ 1. terraform init or terraform init --reconfigure (if you want to make sure with new configure which new update likes upgrade provider version, ...)
ββββββ 2. terraform plan -destroy
ββββββ 3. terraform destroy -auto-approve
Your first infrastructure after the provisioning will be