Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow setting the username of EC2 instance #52665

Open
wants to merge 1 commit into
base: devel
from

Conversation

Projects
None yet
2 participants
@Duologic
Copy link

Duologic commented Feb 20, 2019

SUMMARY

This change allows us to set a username for an EC2 instance based on its tags.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

contrib/inventory/ec2.py

ADDITIONAL INFORMATION

The documentation uses the -u flag to set the username:

ansible -i ec2.py -u ubuntu us-east-1d -m ping

I think it is good practice to set a tag 'Username' on an EC2 instances, this allows me to automate connecting to the instance without statically providing a username for each instance.

In playbooks I do something similar to this:

    - name: Add instances to inventory
      add_host: 
        hostname: '{{ item.public_ip_address }}'
        ansible_ssh_user: '{{ item.tags.Username }}'
      loop: "{{ ec2.instances }}"

@Duologic Duologic force-pushed the Duologic:ec2_inventory_username_variable branch from 6e4bde6 to 741f9b2 Feb 20, 2019

@ansibot

This comment has been minimized.

Copy link
Contributor

ansibot commented Feb 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.