Git Product home page Git Product logo

ansible-role-sudo's Introduction

Sudo

Ansible Galaxy Build Status Latest tag Gitter chat

A role for managing sudo.

This role uses sudoers.d to manage the sudo capabilities of your users. Each user gets its own sudoers.d file. This means the role can be used from multiple roles to add and manage new users without interfering with the other users/roles.

The defaults and aliases however can only be managed from one location and should not be specified if you add this role as a dependency to your own role.

Following roles where designed to neatly work together with this role:

The management-user role combines all these roles in one easy to use role.

Requirements

  • Hosts should be bootstrapped for ansible usage (have python,...)
  • Root privileges, eg become: yes
  • Sudo should be available

Role Variables

Variable Description Default value
sudo_list List of users and their sudo settings (see details!) []
sudo_list_host List of users and their sudo settings (see details!) []
sudo_list_group List of users and their sudo settings (see details!) []
sudo_default_sudoers Restore default sudoers file if altered? no
sudo_default_sudoers_src_path Path (local) to default sudoers file path to included default file
sudo_defaults List of defaults []
sudo_host_aliases List of host aliases (see details!) []
sudo_user_aliases List of user aliases (see details!) []
sudo_runas_aliases List of run as aliases (see details!) []
sudo_cmnd_aliases List of command aliases (see details!) []
sudo_sudoersd_dir Sudoersd directory '/etc/sudoers.d'

sudo_list details

sudo_list, sudo_list_host and sudo_list_group are merged when managing the sudo settings. You can use the host and group lists to specify users settings per host or group off hosts.

The sudo list allows you to define which users sudo settings must be managed. Each item in the list can have following attributes:

Variable Description Required Default
hosts Hosts yes /
as Operators yes /
commands Commands yes /
nopasswd No password sudo? no no
Example sudo_list
sudo_list:
  - name: root
    sudo:
      hosts: ALL
      as: ALL
      commands: ALL
  - name: user1
  - name: user2
    sudo:
      hosts: ALL
      as: ALL
      commands: ALL
      nopasswd: yes

sudo_***_aliases details

The aliases lists allow you to specify multiple aliases. Each item in the list has a name and an alias.

Variable Description Required Default
name Name of the alias yes /
alias Alias yes /
Example sudo_***_aliases
sudo_***_aliases:
  - name: EXAMPLE1
    alias: 'shutdown'
  - name: EXPAMPLE2
    alias: 'test, test1, test2'

Dependencies

None.

Example Playbook

---
- hosts: servers
  roles:
  - { role: GROG.sudo, become: yes }

Inside group_vars/servers.yml:

sudo_list_group:
  - name: user
    sudo:
      hosts: ALL
      as: ALL
      commands: ALL

Contributing

All assistance, changes or ideas welcome!

Author

By G. Roggemans

License

MIT

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.