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

From wikieduonline
Jump to navigation Jump to search
Tags: Mobile web edit, Mobile edit
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
  
(Pending to validate)
+
* https://docs.ansible.com/ansible/latest/collections/amazon/aws/ec2_module.html
  
 
  #!/usr/bin/env ansible-playbook  
 
  #!/usr/bin/env ansible-playbook  
 
   
 
   
  - hosts: localhost
+
  - [[hosts:]] localhost
   connection: local
+
   [[connection:]] local
   become: False
+
   [[become:]] False
 
   
 
   
 
   tasks:
 
   tasks:
     - amazon.aws.ec2:
+
     - amazon.aws.[[ec2]]:
 
         [[key_name]]: mykey
 
         [[key_name]]: mykey
 
         region: us-east-1
 
         region: us-east-1
         instance_type: t3.nano
+
         [[instance_type]]: [[t3.nano]]
         image: ami-07c1207a9d40bc3bd
+
         image: [[ami]]-07c1207a9d40bc3bd
 
         [[vpc_subnet_id:]] subnet-968913da
 
         [[vpc_subnet_id:]] subnet-968913da
 
         wait: yes
 
         wait: yes
Line 60: Line 60:
 
== Related terms ==
 
== Related terms ==
 
* [[Ansible playbooks examples]]
 
* [[Ansible playbooks examples]]
* <code>[[aws ec2 run-instances]]</code>
+
* <code>[[aws ec2 run-instances]]</code>, <code>[[aws ec2 describe-instances]]</code>
 
* <code>[[aws configure list]]</code>
 
* <code>[[aws configure list]]</code>
 +
* [[amazon.aws.ec2_key]]
 +
* [[Manage AWS infrastructure using Ansible]]
 +
* [[Create VM]]
 +
* [[Terraform]]: <code>[[aws_instance]]</code>
  
 
== See also ==
 
== See also ==

Latest revision as of 06:15, 31 March 2022

#!/usr/bin/env ansible-playbook 

- hosts: localhost
  connection: local
  become: False

  tasks:
    - amazon.aws.ec2:
       key_name: mykey
       region: us-east-1
       instance_type: t3.nano
       image: ami-07c1207a9d40bc3bd
       vpc_subnet_id: subnet-968913da
       wait: yes
       count: 1
       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: YOUR_KEY_NAME
      profile: XXXX 
      region: us-east-1
      instance_type: t3.nano
      image: ami-0f4768a55eaaac3d7
      wait: yes
      count: 1 
      assign_public_ip: no 


Errors[edit]

WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see details

PLAY [localhost] *****************************************************************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************************************************************
ok: [localhost]

TASK [amazon.aws.ec2] ************************************************************************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "No handler was ready to authenticate. 1 handlers were checked. ['HmacAuthV4Handler'] Check your credentials"}

PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0


Related terms[edit]

See also[edit]

Advertising: