nordvpn

Create EC2 instance with Ansible

Create EC2 instance with Ansible

In this tutorial I will show you simple Ansible playbook to create EC2 instance with Ansible.

Ansible is a radically simple IT automation engine that automates cloud provisioning, configuration management, application deployment, intra-service orchestration, and many other IT needs.

Being designed for multi-tier deployments since day one, Ansible models your IT infrastructure by describing how all of your systems inter-relate, rather than just managing one system at a time.

Create EC2 instance with Ansible

Read Also: How to install Ansible

Ansible Playbook

Here is a Ansible playbook to create an EC2 instance.

You might also like: Send notification on slack with Ansible

---
  - name : Create an EC2
    hosts: localhost
    gather_facts: True
    tasks:
      - name: Create an EC2 instance
        ec2:
          key_name: ansible
          group: elk
          instance_type: t2.nano
          image: "{{ ami_id }}"
          region: eu-west-1
          wait: true
          instance_tags:
          Name: ansible-test
        register: ec2

There are lot of other options that you can use to make it more productive such as creating security group or assigning elastic ip to the ec2 instances. For detailed information you can visit Ansible website.

Executing Ansible

Now after configuring the Ansible playbook now its time to see it in action.

ansible-playbook create_ec2.yml --extra-vars="ami_id=(ami id)"

If this article is interesting for you please let me know and share with your friends or colleagues.

Reference: Ansible

Leave a Reply

Your email address will not be published.


*



The reCAPTCHA verification period has expired. Please reload the page.

48-Hour Flash Sale! Courses from just $10.99