Giter Club home page Giter Club logo

users_and_groups's Introduction

Users and Roles

Master: Build Status Develop: Build Status

This roles manages OS users and groups.

Installation and Dependencies

This role has no dependencies.

To install run ansible-galaxy install sansible.users_and_groups or add this to your roles.yml

- name: sansible.users_and_groups
  version: v2.0

and run ansible-galaxy install -p ./roles -r roles.yml

Tags

This role uses two tags: build and maintain

  • build - Ensures that specified groups and users are present.
  • maintain - Ensures users on an already built and configured instance.

Examples

Simple example for creating two users and two groups.

- name: Configure User Access
  hosts: sandbox

  roles:
    - name: sansible.users_and_groups
      sansible_users_and_groups_groups:
        - name: lorem
          system: yes
        - name: ipsum
      sansible_users_and_groups_users:
        - name: lorem.ipsum
          groups:
            - ipsum
            - lorem
          ssh_key: ./lorem.ipsum.pub
        - name: dolor.ament
          groups:
            - ipsum

Creating a jailed SFTP user (cf here for a step-by-step guide):

- name: Configure User Access
  hosts: sandbox

  roles:
    - name: sansible.users_and_groups
      sansible_users_and_groups_authorized_keys_dir: /etc/ssh/authorized_keys
      sansible_users_and_groups_groups:
        - name: sftp_only
      sansible_users_and_groups_users:
        - name: sftp
          group: sftp_only
          home: /mnt/sftp_vol

In most cases you would keep the list of users in external vars file or group|host vars file.

- name: Configure User Access
  hosts: sandbox

  vars_files:
    - "vars/sandbox/users.yml"

  roles:
    - name: sansible.users_and_groups
      sansible_users_and_groups_groups: "{{ base_image.os_groups }}"
      sansible_users_and_groups_users: "{{ base_image.admins }}"

    - name: sansible.users_and_groups
      sansible_users_and_groups_users: "{{ developers }}"

Add selected group to sudoers

- name: Configure User Access
  hosts: sandbox

  vars_files:
    - "vars/sandbox/users.yml"

  roles:
    - name: sansible.users_and_groups
      sansible_users_and_groups_groups: "{{ base_image.os_groups }}"
      sansible_users_and_groups_users: "{{ base_image.admins }}"

    - name: sansible.users_and_groups
      sansible_users_and_groups_users: "{{ developers }}"

    - name: sansible.users_and_groups
      sansible_users_and_groups_sudoers:
        - name: wheel
          user: "%wheel"
          runas: "ALL=(ALL)"
          commands: "NOPASSWD: ALL"

Use whitelist groups option to allow users contextually.

Var file with users:

---

# vars/users.yml

sansible_users_and_groups_groups:
  - name: admins
  - name: developer_group_alpha
  - name: developer_group_beta
sansible_users_and_groups_users:
  - name: admin.user
    group: admins
  - name: alpha.user
    group: alpha_develops
  - name: beta.user
    group: developer_group_beta

In a base image:

---

# playbooks/base_image.yml

- name: Base Image
  hosts: "{{ hosts }}"

  vars_files:
    - vars/users.yml

  roles:
    - role: sansible.users_and_groups
      sansible_users_and_groups_whitelist_groups:
        - admins

    - role: base_image

In a service role:

---

# playbooks/alpha_service.yml

- name: Alpha Service
  hosts: "{{ hosts }}"

  vars_files:
    - vars/users.yml

  roles:
    - role: sansible.users_and_groups
      sansible_users_and_groups_whitelist_groups:
        - admins
        - developer_group_alpha

    - role: alpha_service

users_and_groups's People

Contributors

wojtek-oledzki avatar lobsterdore avatar dennisconrad avatar quater avatar js-kingkong-bot avatar exptom avatar dm avatar moisesrt avatar lechuk47 avatar o-sole-meo avatar

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.