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

From wikieduonline
Jump to navigation Jump to search
Line 13: Line 13:
 
         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

Revision as of 06:14, 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

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

See also

Advertising: