Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
March 30, 2022 03:56 am GMT

Chapter 1: Introduction

Hi everyone! I'm Dhona and this is my first series as well as first post on DEV. Here I'm going to make a series of how to use ansible to automate IAM service (because it's too long to make it in a single post). Alright! If mostly people are busy using ansible to build the infrastructure or deploy application, now I wanna do something different.

As all we know, IAM is the free and most basic service in AWS but please never understimate or skip it. IAM is the first service you need after you created an AWS (root) account. More about IAM, click here!

Before we start, we have to prepare two files just like we use ansible as usual. Those are inventory and playbook. If you've never used ansible, don't worry! Ansible is easy to learn even for those of you who don't have programming knowledge like me.

Inventory

Inventory is where we place list of our servers as the target hosts like this way:

[production]192.168.10.1192.168.10.2

We can use format in INI or YAML as we use it for our playbook. Example above is in INI format. For IAM service, the target host is different. We use our local device (such as laptop) as the target because we'll use ansible to run AWS command.

Ansible For AWS IAM

So, the inventory goes like this:

all:  hosts:    localhost:

I give the file name as host.yml. So, when we run the playbook. We'll go with --inventory host.yml or -i host.yml for short.

Then, we can also use variables and they can be different for each host. For example, let's add variable for password!

all:  hosts:    localhost:      temp_pass: passwordup2U!

Note*: Please note where we place the variable. We'll play more variables in the next section and they should be in the same line with the password variable.

Playbook

Playbook is where we place the tasks. You can divide in a role or create it in a single task file. In this series, we'll use and place it in a single task file because IAM is simple enough. So we don't need too many playbook just for an IAM. Here we'll play tags! I'll tell you the task later, OK!

- name: iam  hosts: localhost  connection: local  gather_facts: no  tasks:

For the playbook file, I give it a name iam.yml.

And last but not least, before we start. Don't forget to setup at least one IAM user on your local device. That's something that goes with aws configure, along with providing access key and secret access key.

Alright! That's it for the Chapter 1. Please go to the Chapter 2 to start with the ansible.


Original Link: https://dev.to/nurulramadhona/chapter-1-introduction-oe7

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To