Giter VIP home page Giter VIP logo

ansible-role-create-user-ansible's Introduction

ansible-role-create-user-ansible

Create the ansible user on each server in the hosts file.

Distros tested

  • Ubuntu 18.04 / 16.04 as a client. It should work on older versions of Ubuntu/Debian based systems.
  • CentOS 7.3
  • CentOS 6.5
  • CentOS 5.9

.gitignore

vi .gitignore
#Insert the following lines
.vaultpass
.retry

Default Settings

  • default_sudo_nopass: yes|no (default yes). yes = passwordless sudo.

Example Playbook create-user-ansible.yml

---
- hosts: '{{inventory}}'
  become: yes
  roles:
  - create-user-ansible

Prep

  • install ansible
  • create keys
  • ssh to client to add entry to known_hosts file
  • configure client server authorized_keys
  • run ansible commands

Usage

Create initial ansible user, using an existing user

  • username: new ansible user to be created
  • ansible_ssh_user: existing user with ssh access
  • --become-method: su|sudo
  • --ask-become-pass: needed if using su or password for sudo
  • inventory: servers from hosts file
  • default_sudo_nopass: passwordless sudo

Passwordless sudo = true (don't prompt for user password when running playbook)

ansible-playbook create-user-ansible.yml --ask-pass --become --become-method=su --ask-become-pass --extra-vars "inventory=all-dev ansible_ssh_user=username123 username=ansible" -i hosts

Passwordless sudo = false (prompt for user password when running playbook)

ansible-playbook create-user-ansible.yml --ask-pass --become --become-method=su --ask-become-pass --extra-vars "inventory=all-dev default_sudo_nopass=false ansible_ssh_user=username123 username=ansible" -i hosts

Notes

RHEL5 / CentOS 5 (Why??)

RHEL5 has a dependency that needs to be installed: python-simplejson
This command will use the raw module to install it:

ansible centos5 -m raw -a "yum install -y python-simplejson" --become --ask-pass --become-method=su --ask-become-pass --extra-vars="ansible_ssh_user=username123" -i hosts-dev

SELinux

If SELinux is enabled/permissive a dependency is needed: libselinux-python
This command will use the raw module to install it:

ansible centos5 -m raw -a "yum install -y libselinux-python" --become --ask-pass --become-method=su --ask-become-pass --extra-vars="ansible_ssh_user=username123" -i hosts-dev

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.