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 8 in Ansible by Alia
13 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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 8 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 in Ansible by Kalgi
    36 views
    0 votes
    1 answer
    0 votes
    1 answer

    Playbook to add ec2 instance to ELB

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

    answered Mar 25 in Ansible by Yesha
    8 views
    +13 votes
    2 answers
    0 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 in Ansible by Anushri
    70 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 11 in Ansible by John
    27 views

    © 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
    "PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.