Getting Started with Ansible 13 - Managing Users

Originally published at: Getting Started with Ansible 13 – Managing Users – LearnLinuxTV

Ansible is an incredible configuration management and provisioning utility that enables you to automate all the things. In this series, you’ll learn everything you need to know in order to use Ansible for your day-to-day administration duties.

1 Like

Hi there!

In this video Jay uses the authorized_key module to send a public ssh key to a managed server automatically. However in the official documentation they are using a slightly different method by picking a file rather than copying the contents of the key:

- name: Set authorized key taken from file
  ansible.posix.authorized_key:
    user: charlie
    state: present
    key: "{{ lookup('file', '/home/charlie/.ssh/id_rsa.pub') }}"

- name: Set authorized keys taken from url
  ansible.posix.authorized_key:
    user: charlie
    state: present
    key: https://github.com/charlie.keys

I’m wondering if this is something new and / or preferable? I suppose it is and Jay simply tried to show the simplest method possible (and I’m not complaining).

Now, I have a bit of a question about this because the docs also say, as you can see from that second example, that you can provide a url to that file in case you are storing everything in a repository as shown in this series. However, I’m not sure how to make this work with a private repository as it’s not very clear. Does anyone have any recommendation on how to handle this?

Thank you, great series I’m really learning so much!