Giter Club home page Giter Club logo

ansible-role-user's Introduction

user

Lint Code Base Ansible Molecule

A simple ansible role to bootstrap user accounts with SSH public key based logins and passwordless sudo.

For something more sophisticated use a different role, the ansible-galaxy role robertdebock.users looks promising.

Requirements

For each user with SSH key based login you need a public key file like this:

files/ssh/$USERNAME.pub

This file will then be deployed to /home/$USERNAME/.ssh/authorized_keys.

Role Variables

Use group_vars/* to deploy the users to specific host groups.

See: defaults/main.yml

If you want to deploy the users on all hosts you can use group_vars/all or pass it as parameters to role (see example below).

Dependencies

None.

Example Playbooks

For this example we will assume you have defined a host group servers in hosts.

In this example the users jane_doe and john_doe are created, will also be part of the group sysadmin and will have passwordless sudo rights.

site.yml

---

- hosts: servers
  roles:
     - { role: jkirk.user, users: [ 'jane_doe', 'john_doe' ], groupname: 'sysadmin', admin: true }

It makes sense to put the user role in a bootstrap-playbook like this:

bootstrap.yml

---
# This playbook prepares the system to be managed by Ansible.
#
# Example:
#
#   ansible-playbook -u root bootstrap.yml

- name: Prepare system to be managed by Ansible
  hosts: all
  become: false
  gather_facts: false
  roles:
    - robertdebock.bootstrap
    - { role: jkirk.user, users: [ 'jane_doe', 'john_doe' ], groupname: 'sysadmin', admin: True }

To run this playbook you would do ansible-playbook -u root -i hosts site.yml

License

MIT

Author Information

Darshaka Pathirana - https://synpro.solutions

ansible-role-user's People

Contributors

jkirk avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

ansible-role-user's Issues

Implement an option to disable a user

If disable: true run the following tasks:

---
- name: Disable user account for {{ item }}
  user:
    name: "{{ item }}"
    password_lock: true
    shell: "/usr/sbin/nologin"
- name: Remove authorized_keys file
  file:
    path: "/home/{{ item }}/.ssh/authorized_keys"
    state: absent
- name: Remove authorized_keys2 file
  file:
    path: "/home/{{ item }}/.ssh/authorized_keys2"
    state: absent

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.