An Interest In:
Web News this Week
- April 20, 2024
- April 19, 2024
- April 18, 2024
- April 17, 2024
- April 16, 2024
- April 15, 2024
- April 14, 2024
November 17, 2022 02:04 pm GMT
Original Link: https://dev.to/syedasadrazadevops/ansible-auto-configure-your-server-for-nginxreactjs-and-laravelphp-env-on-one-click-3m2o
ANSIBLE Auto Configure your server for Nginx|Reactjs and Laravel|php env on ONE click
Let setup the ansible:
you need one "MASTER" and multiple "SLAVE" node to control the slave configuration.
Important
- its an configuration management tool, also open-source.
- we used "YAML" for scripting language.
- it implement worker on "push management" model.
- one "Master" configure multiple servers "nodes".
- it communicate agent/nodes throw "SSH" method.
- script are called "PLAY BOOKS".
- the machain where ansible is installed called "ANSIBLE SERVER".
- the set of commands to be executed in nodes/client called " MODULE"
- metadata of servers or agent/nodes/clients called "Inventory"
- inventory default location will be -->
/etc/ansible/host
How to connect master and slave
create an SSH-KEY and paste the same in all slave servers.
So, you connect with all different nodes through IP with same private-key.
How To Install
apt install ansible
How To Create Inventory
[servers]server_1 ansible_hist= 1.112.113.114[all=vars]ansible_python_interpreter = /usr/bin/python3
How To Check/Verify Inventory
ansible-inventory --list -y ansible-inventory --list -y -i [(inventory)--> /etc/ansible/host]
How To Ping Agent/Nodes
ping the all nodes
ansible all -m ping -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pem
OR
ansible all -m ping -u root
####some use full command to get nodes info####
ansible all -a "free -h" -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pemansible all -a "uptime" -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pemansible all -a "df -h" -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pem
How To Create Play-book.yml
https://www.trainwithshubham.com/blog/ansible-playbooks
- name: This playbook will create a file hosts: all become: true tasks: - name: creating a file file: path: /home/ubuntu/testdemo2.txt state: touch
- name: This Playbook will create a user hosts: all become: true tasks: - name: Create a user Shubham user: name=shubham
- name: This playbook will install Docker hosts: all become: true tasks: - name: Add Docker GPG apt Key apt_key: url: https://download.docker.com/linux/ubuntu/gpg state: present - name: Add Docker Repository apt_repository: repo: deb https://download.docker.com/linux/ubuntu focal stable state: present - name: Install Docker apt: name: docker-ce state: latest
How To Upgrade-all Server by(command)
ansible all -m apt -a "upgrade=yes update_cache=yes cache_valid_time=86400" --become -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pem
How To Run Playbook.yml
ansible-playbook playbook.yml -i [(inventory)--> /etc/ansible/host] --private-key = ~/.ssh/ansiblekey.pem
Original Link: https://dev.to/syedasadrazadevops/ansible-auto-configure-your-server-for-nginxreactjs-and-laravelphp-env-on-one-click-3m2o
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To