Hi All,
I have a simple playbook to create an EC2 instance in my account which is
failing with "ProfileNotFoundError" when runs.
>
[root@ansibleserver ~]# cat /etc/system-release
CentOS Linux release 7.6.1810 (Core)
[root@ansibleserver ~]# ansible --version
ansible 2.4.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules',
u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5
20150623 (Red Hat 4.8.5-39)]
[root@ansibleserver ~]# python --version
Python 2.7.5
[root@ansibleserver ~]# rpm -qa |grep -i boto
python-boto3-1.4.6-5.el7.noarch
python-boto-2.25.0-2.el7.centos.noarch
>
Error:
> 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",
>
Command:
> 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'
>>
>
Playbook:
---
- 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]#
> Could some one help what is the error i am making here?
I see the module "ec2_group" is working fine with "boto3", which created
the security group successfully. But the "ec2" module is failing. Please
suggest.
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/9b79addd-9123-462e-ac7b-b3023e0fa307%40googlegroups.com.