Giter Club home page Giter Club logo

ansible_training's Introduction

Ansible hands-on practice labs.

On the target server:

  • Create the privileged user with which you will run ansible playbooks
useradd ansibleuser
passwd ansibleuser
usermod -s /bin/bash ansibleuser
mkdir /home/ansibleuser
cp /etc/skel/.* /home/ansibleuser
chown -R ansibleuser:ansibleuser /home/ansibleuser

Or you might be interrested in doing that remotely with a script (Careful with the password!!!)

ex: create_ansible_user.sh

#!/bin/bash
 
AUSER=ansibleuser
PASSWD=ansibleuserpasswd
useradd $AUSER && echo $AUSER:"$PASSWD" | chpasswd
usermod -s /bin/bash $AUSER
mkdir /home/$AUSER
cp /etc/skel/.* /home/$AUSER
chown -R $AUSER:$AUSER /home/$AUSER 
echo "$AUSER ALL=(ALL:ALL) PASSWD: ALL" >> /etc/sudoers

ssh root@managedhost 'bash -s' < create_ansible_user.sh

  • Add the user to /etc/sudoers and allow it to use sudo without password

ansibleuser ALL=(ALL:ALL) PASSWD: ALL

On Ansible management host:

  • Log in as Ansible user:

su ansibleuser

  • Generate a pair of RSA keys:

ssh-keygen

  • Copy the public key to the target server

ssh-copy-id ansibleuser@managedhost

Preparing the environment

  • In ansible config file /etc/ansible/ansible.cfg
sudo_user      = ansibleuser
#ask_sudo_pass = True
#ask_pass      = True
  • in the playbook: debianservers.yml
  become: yes
  become_user: ansibleuser

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.