![]() Example 4: Recursiverly Delete a Directory. This will create a directory in the /etc directory setting permissions to 0777. name: create a directory if it doesn’t exist The above play creates a file called nf in the /etc directory setting permissions to 0644. name: Change file ownership, group, and permissions Example 1: Perform Linux File Permissions. The file module is used to carry many file operations including creating files & directories, assigning file permissions, and setting symlinks. The permissions in the previous example can be represented as shown in the last line, The user is assigned read and write permissions, the group is assigned write permissions, and the rest of the world is assigned read permissions. Example 2: Copying Files from Local to Remote Linux. Permissions can also be represented using symbolic representation as shown in the last line. The playbook copies the config file nf from /etc/files/ directory to /srv/ directory as tecmint user with 0644 permissions. name: Copy file with owner and permissions Example 1: Copying Files from Local to Remote Linux. name: Restart network service for interface eth0Īs the name suggests, copy module copies files from one location on the remote machine to a different location on the same machine. name: Start service httpd, if not startedĮxample 3: Restarting a Network Interface enp2s0. The service module allows system administrators to start, stop, update, upgrade and reload services on the system. There is the apt module for APT package management for Debian based, the old yum module for YUM package management and dnf module associated with newer RHEL distributions.īelow are a few examples of how the modules can be used in a playbook: Example 1: Installing the Apache Webserver on RHEL 8 -Įxample 2: Installing the Apache Webserver on Debian 10. Now run the playbook using the below ansible-playbook command.They are relatively easy to guess.To deploy the playbook using the ansible-playbook command.Īssuming you are logged into Ansible controller: Running Ansible-playbook on the Ansible ControllerĮarlier in the previous section, you created the ansible-playbook, which is great, but it is not doing much unless you deploy it. name: Start and Enable Tomcat 10 on sever name: Copy Tomcat service from local to remote name: Change ownership of tomcat directory name: Install Apache Tomcat10 using ansible The next task is to install java, install tomcat, and create necessary folders and permissions for the tomcat directory. The first task is to update your system packages by using the apt command, further creating tomcat user and group. The below playbook contains all the tasks to install tomcat on the remote node. Create a file named my_playbook3.yml inside /etc/ansible folder and paste below code.SSH or login into your any Linux machine.Ansible uses YAML Language to build playbooks which are finally used to deploy or configure the required change. To deploy tomcat, let’s move ahead and create the ansible-playbook. The remote Linux computer is called webserver, and this tutorial uses an inventory group called web.Įnsure your remote machine IP address is inside /etc/ansible/hosts ( either one remote machine or define it as a group) Building tomcat Ansible-playbook on the Ansible ControllerĪnsible is an automation tool used for deploying applications and systems easily it could be Cloud, Services, orchestration, etc. An inventory file and one or more hosts are configured to run Ansible commands and playbooks.This tutorial uses Ubuntu 20.04.3 LTS as the remote node. A remote Linux computer to test out the tomcat installation.In case it is not installed please refer: Install Ansible on Ubuntu Machine.This tutorial will be using Ansible v2.9.18. If you’d like to follow along, be sure you have: This post will be a step-by-step tutorial. Tomcat files and Tomcat directories on a remote node.Running Ansible-playbook on the Ansible Controller.Building tomcat Ansible-playbook on the Ansible Controller.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |