fatal: [localhost]: FAILED! => {
"changed": false,
"module_stderr": "Traceback (most recent call last):\n File \"/tmp/ansible_AeceaE/ansible_module_ec2.py\", line 1725, in <module>\n main()\n File \"/tmp/ansible_AeceaE/ansible_module_ec2.py\", line 1673, in main\n ec2 = ec2_connect(module)\n File \"/tmp/ansible_AeceaE/ansible_modlib.zip/ansible/module_utils/ec2.py\", line 320, in ec2_connect\nAttributeError: 'module' object has no attribute 'ProfileNotFoundError'\n",
ansible-playbook /etc/ansible/playbooks/aws_deployvm_vm.yml -e 'vpcid=vpc-1fb78577 region=ap-south-1 myaccesskey=sometext mysecretkey="sometext" subnet=subnet-e283d88a myami=ami-040c7ad0a93be494e instancetype=t2.micro'
---
- hosts: localhost
vars:
sgname: ansible_mumbai
kpname: mumbai
vmname: apacheinstance
tasks:
- name: creating security group and adding rules
ec2_group:
aws_access_key: "{{myaccesskey}}"
aws_secret_key: "{{mysecretkey}}"
name: "{{sgname}}"
description: ansible
vpc_id: "{{vpcid}}"
region: "{{region}}"
rules:
-
proto: tcp
ports:
- 80
- 22
cidr_ip: 0.0.0.0/0
- rule_desc: allow all port on 80
register: ansible_mumbai_output
- debug:
var: ansible_mumbai_output
- name: creating linux instances
ec2:
aws_access_key: "{{myaccesskey}}"
aws_secret_key: "{{mysecretkey}}"
region: "{{region}}"
key_name: "{{kpname}}"
group_id: "{{ansible_mumbai_output.group_id}}"
instance_type: "{{instancetype}}"
image: "{{myami}}"
vpc_subnet_id: "{{subnet}}"
assign_public_ip: yes
instance_tags:
name: "{{vmname}}"
count_tag:
name: "{{vmname}}"
exact_count: 1
wait: yes
wait_timeout: 120
register: apacheinstance_output
- debug:
var: apacheinstance_output
[root@ansibleserver playbooks]# --
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/9b79addd-9123-462e-ac7b-b3023e0fa307%40googlegroups.com.
[root@ansibleserver ~]# cat .aws/credentials
[user1]
aws_access_key_id = 6JO2WH2PH4Q
aws_secret_access_key = Ky2laT9PwJSqBjDK5
[user2]
aws_access_key_id = JOQNXRWYHM
aws_secret_access_key = gK8stl+rOYYoGGg
[root@ansibleserver ~]# cat .aws/config
[profile user1]
region = ap-south-1
[profile user2]
region = ap-south-1
[root@ansibleserver ~]#
Command Used:
aws_profile=user2 ansible-playbook /etc/ansible/playbooks/aws_deployvm_vm.yml -e 'vpcid=vpc-1fb78577 region=ap-south-1 myaccesskey=NXRWYHM mysecretkey="E748x5" subnet=subnet-e283d88a myami=ami-040c7ad0a93be494e instancetype=t2.micro'
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/29dce282-ebcb-4b96-ae00-9aa5828fa85b%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/29dce282-ebcb-4b96-ae00-9aa5828fa85b%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/iQ1fZDyGCzM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d63937d5-54b9-4cad-b8e0-53b53906b65d%40googlegroups.com.