Difference between revisions of "Ansible: create Amazon ec2 instance"

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
Tags: Mobile web edit, Mobile edit
Line 1: Line 1:
  
 
(Pending to validate)
 
(Pending to validate)
<pre>
 
#!/usr/bin/env ansible-playbook
 
  
- hosts: localhost
+
#!/usr/bin/env ansible-playbook
  become: yes
+
 +
- hosts: localhost
 +
  become: yes
 +
 +
  tasks:
 +
    - amazon.aws.ec2:
 +
        key_name: mykey
 +
        instance_type: [[t2.micro]]
 +
        image: ami-123456
 +
        wait: yes
 +
        group: webserver
 +
        count: 3
 +
        vpc_subnet_id: subnet-29e63245
 +
        assign_public_ip: yes
  
  tasks:
 
    - amazon.aws.ec2:
 
      key_name: mykey
 
      instance_type: [[t2.micro]]
 
      image: ami-123456
 
      wait: yes
 
      group: webserver
 
      count: 3
 
      vpc_subnet_id: subnet-29e63245
 
      assign_public_ip: yes
 
</pre>
 
  
  

Revision as of 14:26, 12 April 2021

(Pending to validate)

#!/usr/bin/env ansible-playbook 

- hosts: localhost
  become: yes

  tasks:
    - amazon.aws.ec2:
       key_name: mykey
       instance_type: t2.micro
       image: ami-123456
       wait: yes
       group: webserver
       count: 3
       vpc_subnet_id: subnet-29e63245
       assign_public_ip: yes


#!/usr/bin/env ansible-playbook
 - name: Status ec2 instances
  hosts: 127.0.0.1 
  vars:
    ansible_python_interpreter: "/usr/bin/python3"
  connection: local
  tasks:
   - ec2:
      key_name: oam-deploy
      profile: 3629 
      region: us-east-1
      instance_type: t3.nano
      image: ami-0f4768a55eaaac3d7
      wait: yes
      count: 1 
      assign_public_ip: no 

Related terms

See also

Advertising: