Code Monkey home page Code Monkey logo

ansible_automation's Introduction

Ansible

Ansible is an open source configuration management, software provisioning and application deployment tool.

Use cases of Ansible:

  • Provisioning new resources

  • Configuration management

  • Continuous delivery

  • Security compliance

  • Application deployment

  • Orchestration

Change Ansible instance Hostname

hostnamectl set-hostname [hostname] 

Install Python latest version (on Control node and Managed host)

yum install python3 -y

By default, python3 is the command to run python commands. to use just python, use "alternatives" command. (on Control node and Managed host)

alternatives --set python /usr/bin/python3 python3 --version

Install PIP

yum -y install python3-pip
python --version

Create a new user for ansible administration & grant admin access to the user (on Control node and Managed host)

Create ansible user

useradd ansadmin
passwd ansadmin

Below command adds ansadmin to sudoers file. But I strongly recommended using "visudo" command if you are aware vi or nano editor. (on Control node and Managed host)

echo "ansadmin ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Using key-based authentication is advised. If you are still at the learning stage use password-based authentication (on Control node and Managed host)

#sed command replaces "PasswordAuthentication no to yes" without editing file 
sed -ie 's/PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
sudo service sshd reload
#Install Ansible as a ansadmin user (on Control node)
su - ansadmin
pip3 install ansible --user

Note: Ansible must be installed as a user (here ansadmin)

check for ansible version

ansible --version

Add managed host entries in /etc/hosts file on control node. This is only required when you don’t have local DNS server configured.

Log in as a ansadmin user on master and generate ssh key (on Control node)

Create a private and public key

ssh-keygen
# Copy keys into all ansible managed hosts (on Control node)
ssh-copy-id -i ~/.ssh/id_rsa.pub ansadmin@<target-server>

Validation test Create a directory /etc/ansible and create an inventory file called "hosts" add control node IP address in it.

Run ansible command as ansadmin user it should be successful (Master)

ansible all -m ping

ansible_automation's People

Contributors

lanru2001 avatar

Stargazers

 avatar

Watchers

 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.