I am getting below error while invoking ansible playbook from Jenkins

50 views
Skip to first unread message

lakshminarayanan R

unread,
Aug 2, 2020, 6:37:04 AM8/2/20
to Ansible Project
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.ap-northeast-1.amazonaws.com/"
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\", line 160, in _new_conn\n    (self._dns_host, self.port), self.timeout, **extra_kw\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 84, in create_connection\n    raise err\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 74, in create_connection\n    sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused

vinoth kumar

unread,
Aug 2, 2020, 7:43:55 AM8/2/20
to ansible...@googlegroups.com
It’s error 111 connection refused . Check port 22 from controller to target servers .




On Sun 2. Aug 2020 at 12:37, lakshminarayanan R <laksk...@gmail.com> wrote:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.ap-northeast-1.amazonaws.com/"
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\", line 160, in _new_conn\n    (self._dns_host, self.port), self.timeout, **extra_kw\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 84, in create_connection\n    raise err\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 74, in create_connection\n    sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused

--
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/4cb805a2-78b8-45ae-87f0-60a740ea3146o%40googlegroups.com.

lakshminarayanan R

unread,
Aug 2, 2020, 7:51:42 AM8/2/20
to Ansible Project
thanks for your reply 

Playbook is working fine from Linux box while the trigger playbook from Jenkins and getting this error and Jenkins has 22 port open status. 


On Sunday, August 2, 2020 at 5:13:55 PM UTC+5:30, vinoth kumar wrote:
It’s error 111 connection refused . Check port 22 from controller to target servers .



On Sun 2. Aug 2020 at 12:37, lakshminarayanan R <laksk...@gmail.com> wrote:
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://ec2.ap-northeast-1.amazonaws.com/"
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "Traceback (most recent call last):\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/connection.py\", line 160, in _new_conn\n    (self._dns_host, self.port), self.timeout, **extra_kw\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 84, in create_connection\n    raise err\n  File \"/usr/local/lib/python3.6/site-packages/urllib3/util/connection.py\", line 74, in create_connection\n    sock.connect(sa)\nConnectionRefusedError: [Errno 111] Connection refused

--
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...@googlegroups.com.

Dick Visser

unread,
Aug 2, 2020, 4:52:46 PM8/2/20
to ansible...@googlegroups.com
What playbook are we talking about?
I didn't see any in your email.

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/293cf960-355c-48da-abde-f69241ece32bo%40googlegroups.com.
--
Sent from a mobile device - please excuse the brevity, spelling and punctuation.

lakshminarayanan R

unread,
Aug 2, 2020, 10:31:08 PM8/2/20
to ansible...@googlegroups.com
I wrote the playbook for creating a resource on AWS environments, I am using the IAM CrossAccount role for this. I ran the playbook from EC2 Linux instances, it has created the resource on the AWS child account but invoking playbook from Jenkins, I am getting boto3 endpoint issue. I attached my sample playbook for your references.

---
- name: EC2 instances creation
  hosts: localhost
 
  tasks:
    - name: environment settings
      command: "{{ item }}"
      with_items:
       - http_proxy:
       - https_proxy:
       - NO_PROXY: 169.254.169.254
       
    - sts_assume_role:
        role_arn: "arn:aws:iam::XXXXXXXX:role/XXXXXXXXXXX_Role"
        role_session_name: "2test"
        region: us-east-1
      register: assumed_ec2_role
 
    - ec2_instance:
        aws_access_key: "{{ assumed_ec2_role.sts_creds.access_key }}"
        aws_secret_key: "{{ assumed_ec2_role.sts_creds.secret_key }}"
        security_token: "{{ assumed_ec2_role.sts_creds.session_token }}"
        name: "cloud-instance"
        #key_name: "prod-ssh-key"
        vpc_subnet_id: XXXXXXXXXX-x
        instance_type: t2.large
        region: "{{ assumed_ec2_role.region }}"
        security_group: default
        network:
            assign_public_ip: false
        image_id: XXXXXXXXXXXXXXXXx
        tags:
            Environment: Testing
            Name: cloud_instances



Dick Visser

unread,
Aug 3, 2020, 12:48:39 AM8/3/20
to ansible...@googlegroups.com
I think the issue is with how you configure your environment wrt proxies. Apparently you need that, but it didn't work, as your error pointed out. 

That first command task is probably where you try to set those vars, but that won't work.


lakshminarayanan R

unread,
Aug 3, 2020, 3:38:13 AM8/3/20
to ansible...@googlegroups.com
I tried multiple ways but I am not getting error messages while running playbook in EC2  Linux instances the same playbook throwing error and just I modified my the playbook.

- name: EC2 instance creation
  hosts: localhost
  connection: local
  gather_facts: flase
  vars:
    proxy_env:
        http_proxy: http://localhost:<port>
        https_proxy: http://localhost:<port>
        NO_PROXY: 169.254.169.254

  tasks:

    - sts_assume_role:
        role_arn: "arn:aws:iam::xxxxxxxxxxxxx:role/XXXXXXXXXX_CrossAccount_Role"
        role_session_name: "iopec2test"
        region: ap-northeast-1
      register: assumed_ec2_role
      environment: "{{ proxy_env }}"
      ignore_unreachable: yes

Reply all
Reply to author
Forward
0 new messages