Uploaded image for project: 'Ansible Cloud Automation'
  1. Ansible Cloud Automation
  2. ACA-1978

[community.aws/1725] community.aws.aws_ssm connection does not consider the variable ansible_aws_ssm_profile, maybe others

XMLWordPrintable

    • False
    • Hide

      None

      Show
      None
    • False

      https://github.com/ansible-collections/community.aws/issues/1725

          1. Summary

      the variable: ansible_aws_ssm_profile is not taking effect when used.
      The only workaround I found is to use the export AWS_PROFILE=[profile name] in bash

          1. Issue Type

      Bug Report

          1. Component Name

      community.aws.aws_ssm connection

          1. Ansible Version

      ```console (paste below)
      $ ansible --version
      ansible [core 2.14.2]
      config file = ~/gitlab/ansible-cda-tools/ansible.cfg
      configured module search path = ['~/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
      ansible python module location = ~/Library/Python/3.9/lib/python/site-packages/ansible
      ansible collection location = ~/gitlab/ansible-cda-tools/collections
      executable location = ~/Library/Python/3.9/bin/ansible
      python version = 3.9.16 (main, Dec 7 2022, 10:16:11) [Clang 14.0.0 (clang-1400.0.29.202)] (/usr/local/opt/python@3.9/bin/python3.9)
      jinja version = 3.1.2
      libyaml = True

      ```

          1. Collection Versions

      ```console (paste below)
      $ ansible-galaxy collection list

      1. ~/gitlab/ansible-cda-tools/collections/ansible_collections
        Collection Version
                                                    • -------
                                                      amazon.aws 1.1.0
                                                      ansible.netcommon 1.1.2
                                                      community.akamai 1.0.0
                                                      community.aws 1.1.0
                                                      community.crypto 2.1.0
                                                      community.crypto_entrust 1.1.3
                                                      community.docker 1.9.0
                                                      community.general 0.1.1
                                                      community.keystore 1.0.0
                                                      community.mysql 1.0.0
                                                      community.mysql 1.0.3
                                                      f5networks.f5_modules 1.5.0
                                                      servicenow.servicenow 1.0.6
      1. ~Library/Python/3.9/lib/python/site-packages/ansible_collections
        Collection Version
                                                              • -------
                                                                amazon.aws 5.2.0
                                                                ansible.netcommon 4.1.0
                                                                ansible.posix 1.5.1
                                                                ansible.utils 2.9.0
                                                                ansible.windows 1.13.0
                                                                arista.eos 6.0.0
                                                                awx.awx 21.11.0
                                                                azure.azcollection 1.14.0
                                                                check_point.mgmt 4.0.0
                                                                chocolatey.chocolatey 1.4.0
                                                                cisco.aci 2.3.0
                                                                cisco.asa 4.0.0
                                                                cisco.dnac 6.6.3
                                                                cisco.intersight 1.0.23
                                                                cisco.ios 4.3.1
                                                                cisco.iosxr 4.1.0
                                                                cisco.ise 2.5.12
                                                                cisco.meraki 2.15.0
                                                                cisco.mso 2.2.1
                                                                cisco.nso 1.0.3
                                                                cisco.nxos 4.0.1
                                                                cisco.ucs 1.8.0
                                                                cloud.common 2.1.2
                                                                cloudscale_ch.cloud 2.2.4
                                                                community.aws 5.2.0
                                                                community.azure 2.0.0
                                                                community.ciscosmb 1.0.5
                                                                community.crypto 2.10.0
                                                                community.digitalocean 1.23.0
                                                                community.dns 2.5.0
                                                                community.docker 3.4.0
                                                                community.fortios 1.0.0
                                                                community.general 6.3.0
                                                                community.google 1.0.0
                                                                community.grafana 1.5.3
                                                                community.hashi_vault 4.1.0
                                                                community.hrobot 1.7.0
                                                                community.libvirt 1.2.0
                                                                community.mongodb 1.4.2
                                                                community.mysql 3.5.1
                                                                community.network 5.0.0
                                                                community.okd 2.2.0
                                                                community.postgresql 2.3.2
                                                                community.proxysql 1.5.1
                                                                community.rabbitmq 1.2.3
                                                                community.routeros 2.7.0
                                                                community.sap 1.0.0
                                                                community.sap_libs 1.4.0
                                                                community.skydive 1.0.0
                                                                community.sops 1.6.0
                                                                community.vmware 3.3.0
                                                                community.windows 1.12.0
                                                                community.zabbix 1.9.1
                                                                containers.podman 1.10.1
                                                                cyberark.conjur 1.2.0
                                                                cyberark.pas 1.0.17
                                                                dellemc.enterprise_sonic 2.0.0
                                                                dellemc.openmanage 6.3.0
                                                                dellemc.os10 1.1.1
                                                                dellemc.os6 1.0.7
                                                                dellemc.os9 1.0.4
                                                                dellemc.powerflex 1.5.0
                                                                dellemc.unity 1.5.0
                                                                f5networks.f5_modules 1.22.0
                                                                fortinet.fortimanager 2.1.7
                                                                fortinet.fortios 2.2.2
                                                                frr.frr 2.0.0
                                                                gluster.gluster 1.0.2
                                                                google.cloud 1.1.2
                                                                grafana.grafana 1.1.0
                                                                hetzner.hcloud 1.9.1
                                                                hpe.nimble 1.1.4
                                                                ibm.qradar 2.1.0
                                                                ibm.spectrum_virtualize 1.11.0
                                                                infinidat.infinibox 1.3.12
                                                                infoblox.nios_modules 1.4.1
                                                                inspur.ispim 1.2.0
                                                                inspur.sm 2.3.0
                                                                junipernetworks.junos 4.1.0
                                                                kubernetes.core 2.3.2
                                                                lowlydba.sqlserver 1.3.1
                                                                mellanox.onyx 1.0.0
                                                                netapp.aws 21.7.0
                                                                netapp.azure 21.10.0
                                                                netapp.cloudmanager 21.22.0
                                                                netapp.elementsw 21.7.0
                                                                netapp.ontap 22.2.0
                                                                netapp.storagegrid 21.11.1
                                                                netapp.um_info 21.8.0
                                                                netapp_eseries.santricity 1.4.0
                                                                netbox.netbox 3.10.0
                                                                ngine_io.cloudstack 2.3.0
                                                                ngine_io.exoscale 1.0.0
                                                                ngine_io.vultr 1.1.3
                                                                openstack.cloud 1.10.0
                                                                openvswitch.openvswitch 2.1.0
                                                                ovirt.ovirt 2.4.1
                                                                purestorage.flasharray 1.16.2
                                                                purestorage.flashblade 1.10.0
                                                                purestorage.fusion 1.3.0
                                                                sensu.sensu_go 1.13.2
                                                                splunk.es 2.1.0
                                                                t_systems_mms.icinga_director 1.32.0
                                                                theforeman.foreman 3.8.0
                                                                vmware.vmware_rest 2.2.0
                                                                vultr.cloud 1.7.0
                                                                vyos.vyos 4.0.0
                                                                wti.remote 1.0.4

      ```

          1. AWS SDK versions

      ```console (paste below)
      $ pip show boto boto3 botocore
      Name: boto
      Version: 2.49.0
      Summary: Amazon Web Services Library
      Home-page: https://github.com/boto/boto/
      Author: Mitch Garnaat
      Author-email: mitch@garnaat.com
      License: MIT
      Location: ~/Library/Python/3.9/lib/python/site-packages
      Requires:
      Required-by:

      WARNING: Package(s) not found: boto
      Name: boto3
      Version: 1.26.61
      Summary: The AWS SDK for Python
      Home-page: https://github.com/boto/boto3
      Author: Amazon Web Services
      Author-email:
      License: Apache License 2.0
      Location: ~/Library/Python/3.9/lib/python/site-packages
      Requires: botocore, s3transfer, jmespath
      Required-by:

      Name: botocore
      Version: 1.29.61
      Summary: Low-level, data-driven core of boto 3.
      Home-page: https://github.com/boto/botocore
      Author: Amazon Web Services
      Author-email:
      License: Apache License 2.0
      Location: ~/Library/Python/3.9/lib/python/site-packages
      Requires: jmespath, urllib3, python-dateutil
      Required-by: s3transfer, boto3

      ```

          1. Configuration

      ```console (paste below)
      $ ansible-config dump --only-changed
      CACHE_PLUGIN(~/gitlab/ansible-cda-tools/ansible.cfg) = jsonfile
      CACHE_PLUGIN_CONNECTION(~/gitlab/ansible-cda-tools/ansible.cfg) = /tmp/facts_cache
      CACHE_PLUGIN_TIMEOUT(~/gitlab/ansible-cda-tools/ansible.cfg) = 10
      CALLBACKS_ENABLED(~/gitlab/ansible-cda-tools/ansible.cfg) = ['profile_tasks']
      COLLECTIONS_PATHS(~/gitlab/ansible-cda-tools/ansible.cfg) = ['~/gitlab/ansible-cda-tools/collections']
      CONFIG_FILE() = ~/gitlab/ansible-cda-tools/ansible.cfg
      DEFAULT_DEBUG(~/gitlab/ansible-cda-tools/ansible.cfg) = False
      DEFAULT_GATHERING(~/gitlab/ansible-cda-tools/ansible.cfg) = smart
      DEFAULT_HOST_LIST(~/gitlab/ansible-cda-tools/ansible.cfg) = ['~/gitlab/ansible-cda-tools/inventory']
      DEFAULT_LOG_PATH(~/gitlab/ansible-cda-tools/ansible.cfg) = ~/gitlab/ansible-cda-tools/ansible.log
      DEFAULT_ROLES_PATH(~/gitlab/ansible-cda-tools/ansible.cfg) = ['~/gitlab/ansible-cda-tools/roles']
      HOST_KEY_CHECKING(~/gitlab/ansible-cda-tools/ansible.cfg) = False
      ```

          1. OS / Environment

      MacOS Ventura 13.0.1

          1. Steps to Reproduce

      <!--- Paste example playbooks or commands between quotes below -->
      ```yaml (paste below)

      • name: Wait for connection to be available
        hosts: local
        connection: local
        gather_facts: false
        vars:
        ansible_connection: aws_ssm

      ansible_aws_ssm_region: us-east-1
      ansible_aws_ssm_profile: commerce1
      ansible_aws_ssm_instance_id: i-xxxxx

      ansible_aws_ssm_bucket_name: [hidden]
      ansible_aws_ssm_s3_addressing_style: virtual
      tasks:

      • name: Wait for connection
        wait_for_connection:
      • name: aws-cli
        raw: which nano
      • name: ping
        ping:

      ```

          1. Expected Results

      I expect to be able to connect to the ec2 instance in the aws account of the profile that is in my .aws/config
      And run the tasks

      for now only works with workaround of declaring the aws profile in bash cli with export AWS_PROFILE=commerce1
      ```
      TASK [Wait for connection] ********************************************************************************************************************************************************************************************************************************************************************
      task path: ~/gitlab/ansible-cda-tools/PlayBooks/ansible_ssm_connection/ssm_connection_test_playbook.yml:36
      Friday 24 February 2023 18:27:38 -0500 (0:00:00.032) 0:00:00.032 *******
      redirecting (type: connection) ansible.builtin.aws_ssm to community.aws.aws_ssm
      wait_for_connection: attempting ping module test
      [WARNING]: Reset is not implemented for this connection
      <localhost> ESTABLISH SSM CONNECTION TO: i-xxxxxx
      <localhost> SSM CONNECTION ID: botocore-session-[hiddne]
      <localhost> EXEC echo ~

      ```

          1. Actual Results

      ```console (paste below)

      PLAYBOOK: ssm_connection_test_playbook.yml *********************************************************************************************************************************************************************
      1 plays in PlayBooks/ansible_ssm_connection/ssm_connection_test_playbook.yml

      PLAY [Wait for connection to be available] *************************************

      TASK [Wait for connection] *************************************************************************************************************************************************************************************
      task path: ~/gitlab/ansible-cda-tools/PlayBooks/ansible_ssm_connection/ssm_connection_test_playbook.yml:36
      Friday 24 February 2023 18:29:44 -0500 (0:00:00.037) 0:00:00.037 *******
      redirecting (type: connection) ansible.builtin.aws_ssm to community.aws.aws_ssm
      wait_for_connection: attempting ping module test
      [WARNING]: Reset is not implemented for this connection
      <localhost> ESTABLISH SSM CONNECTION TO: i-xxxxx
      <localhost> ssm_retry: attempt: 0, caught exception(An error occurred (TargetNotConnected) when calling the StartSession operation: i-xxxxx is not connected.) from cmd (echo ~...), pausing for 0 seconds
      <localhost> ESTABLISH SSM CONNECTION TO: i-xxxxx
      <localhost> ssm_retry: attempt: 1, caught exception(An error occurred (TargetNotConnected) when calling the StartSession operation: i-xxxxx is not connected.) from cmd (echo ~...), pausing for 1 seconds

      ```

          1. Code of Conduct
      • [X] I agree to follow the Ansible Code of Conduct

              Unassigned Unassigned
              jrouleau Jill Rouleau
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: