Skip to content

ElaoInfra/ansible-role-users

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Ansible Role Platforms License

Ansible Role: Users

This role will assume the setup of users accounts and ssh keys:

It's part of the ELAO Ansible stack but can be used as a stand alone component.

Requirements

  • Ansible 1.8.0+

Dependencies

None.

Installation

Ansible 2+

Using ansible galaxy cli:

ansible-galaxy install elao.users,2.0

Using ansible galaxy requirements file:

- src:     elao.users
  version: 2.0

Ansible 1 (no longer maintained)

Using ansible galaxy cli:

ansible-galaxy install elao.users,1.0

Using ansible galaxy requirements file:

- src:     elao.users
  version: 1.0

Role Handlers

None

Role Variables

Name Default Type Description
elao_users Array Array List of unix users.
elao_users.name - String Username.
elao_users.group - String User's primary group.
elao_users.groups - Array Array of user's secondary groups.
elao_users_groups - Array Array of groups to be created.
elao_users_groups.name - String Name of the group to manage.
elao_users_groups.system - Boolean If yes, indicates that the group created is a system group.
elao_users_authorized_keys Array Array List of authorized ssh keys
elao_users_authorized_keys.user - String Username.
elao_users_authorized_keys.keys Array Array Collection of user's ssh keys.
elao_users_authorized_keys.options Array Array List of ssh options for the user.

Defining users

The elao_userskey will allow to define our users by:

  • A name
  • A main group
  • Some secondary groups
  • Some exclusive authorized keys
  • Some private/public keys

Example

elao_users:
  - name:   foo
    group:  users
    groups: ['sudo']
    authorized_keys:
      - "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
      - "no-port-forwarding,from=\"10.0.1.*\" {{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}
    keys:
      - name:    id_rsa
        public:  "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
        private: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
    gpg_keys:
      - key:    FOOOBAAR
        public: "{{ lookup('file', playbook_dir ~ '/files/users/gpg_keys/[email protected]') }}"
        secret: "{{ lookup('file', playbook_dir ~ '/files/users/gpg_keys/[email protected]') }}"

Creating group

You can create your own group by using the elao_users_groups by specifying:

  • A name
  • If the group is a "system group"

Example

elao_users_groups:
  - name: ops
    system: false

Managing users keys

Example

elao_users_authorized_keys:
  - user: gateway
    keys:
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
        state: absent
      - "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
    options:
      - no-pty
      - no-X11-forwarding
  - user: root
    keys:
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
  - user: elao
    keys:
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"
      - key: "{{ lookup('file', playbook_dir ~ '/files/users/keys/[email protected]') }}"

Example playbook

- hosts: servers
  roles:
     - { role: elao.users }

Licence

MIT

Author information

ELAO (http://www.elao.com/)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •