Playbook to start ec2 instance

0 votes
Can I please have the idea of how to write the playbook to start an ec2 instance on AWS? Thank you :)
Apr 9, 2019 in Ansible by Alia
634 views

1 answer to this question.

0 votes
- name: Create an ec2 instance
  hosts: web
  gather_facts: false
  vars:
      region: us-east-1
      instance_type: t2.micro
      ami: ami-05ea7729e394412c8
      keypair: priyajdm
  tasks:
    - name: Create an ec2 instance
      ec2:
         aws_access_key: '********************'
         aws_secret_key: '****************************************'
         key_name: "{{ keypair }}"
         group: launch-wizard-26
         instance_type: "{{ instance_type }}"
         image: "{{ ami }}"
         wait: true
         region: "{{ region }}"
         count: 1
         vpc_subnet_id: subnet-02f498e16fd56c277
         assign_public_ip: yes
    register: ec2

You could try this and have a look at this blog for better understanding.

    answered Apr 9, 2019 by Kalgi

    Related Questions In Ansible

    0 votes
    0 answers

    Error while executing playbook to start ec2 instance

    I have a playbook that starts an ...READ MORE

    Mar 29, 2019 in Ansible by Kalgi
    1,125 views
    0 votes
    1 answer

    Ansible playbook to automate security configurations of an EC2 instance

    Hey @Kiara, your indentation is very wrong. ...READ MORE

    answered Jan 24, 2019 in Ansible by Harsh
    815 views
    0 votes
    1 answer

    Playbook to add ec2 instance to ELB

    Hey, @Kishore, try something like this: - hosts: ...READ MORE

    answered Mar 26, 2019 in Ansible by Yesha
    608 views
    0 votes
    1 answer

    How to launch an EC2 instance using Ansible Playbook?

    Hi@akhtar, Ansible has one module named ec2. This ...READ MORE

    answered Aug 12, 2020 in Ansible by MD
    • 95,460 points
    2,072 views
    +15 votes
    2 answers

    Git management technique when there are multiple customers and need multiple customization?

    Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

    answered Mar 27, 2018 in DevOps & Agile by DragonLord999
    • 8,450 points
    4,048 views
    +2 votes
    1 answer
    0 votes
    1 answer

    Playbook to backup all mysql databases

    Hey @Ruth, you could use a playbook, ...READ MORE

    answered Feb 4, 2019 in Ansible by Anushri
    3,046 views
    0 votes
    1 answer

    How do i set multiple authorized keys to my ansible playbook?

    Try this: - name: Set up multiple authorized ...READ MORE

    answered Feb 12, 2019 in Ansible by John
    1,456 views
    webinar REGISTER FOR FREE WEBINAR X
    REGISTER NOW
    webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP