Giter Site home page Giter Site logo

ansible-demo's Introduction

#configure target server (ubuntu instance using ansible server)

  • Spin up two servers on AWS (ubuntu servers) image

  • in the Ansible server, install Ansible sudo apt update sudo apt install ansible

  • configure passwordless authentication so that the Ansible server can access target servers without any password

  • in the ansible server, generate public/private key: ssh-keygen this will generate public, and private keys and store them in /home/ubuntu/.ssh folder

  • do the same in the target server, ssh-keygen

  • add the public key in the target server--> authorised_keys folder to implement passwordless authentication by default the .pem key details will be there in this server (keypair used while creating the server) -- overwrite this public key on that image

  • now from the Ansible server, SSH into the target server ssh target-server-private-ipv4 image

  • we are now logged in to the target server without a password

  • now we can write an Ansible playbook to manage the target servers

    • inventory file: a simple txt file with private IP addresses of target servers
  • add the target server's private IP in this file

  • Ansible ADHOC commands ansible -i inventory.txt all -m "shell" -a "touch devops calls" this command will execute shell command [-m "shell" indicates use shell module to execute the later commands] [-a indicates to execute the command in target server ] image

  • we can execute simple shell commands like this image

  • for managing different types of servers like webserver/ db servers/ test server/ staging servers etc group them in the inventory file using [] image

  • at runtime give the specific server group name to configure the changes in the specific server group

    image here, we are creating demo files, in db servers with dbserver name and in webserver with webserver name image image The same is visible on the respective servers

  • we write Ansible playbook when there are multiple tasks to be performed if one or two are to then go with Ansible ad-hoc commands

    • playbook is a Yaml.manifest file

    image

  • run the playbook file using ansible-playbook -i inventory.txt my-first-playbook image

  • Verify NGINX running in the target server image

  • in real-time usecase ansible-playbook will be used to manage Kubernetes clusters

ansible-demo's People

Contributors

hemu07 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.