DevOps Classroomnotes 03/Aug/2022

Ansible contd…

  • In Ansible we can execute the activity by using
    • adhoc command:
      • Can execute any ansible module
      • Good for rare activities
      • history cannot be maintained
    • Playbook: declaring the whole deployment as a yaml file
      • Good for automating activities used multiple times (frequently)
      • Playbook can be version controlled, so we will have history of all of the changes done.

Lets create a file using Ansible

  • Refer Here for the file module
  • Adhoc command:
    • ansible -m <module-name> -a <parameters/arguments> -i <inventory> all
    • module-name => ansible.builtin.file
    • arguments:
      • state argument: touch
      • path: /tmp/1.txt
    • ansible -m ansible.builtin.file -a 'path=/tmp/1.txt state=touch' all
  • Playbook:
---
- name: learning playbooks
  hosts: all
  become: no
  tasks:
    - name: create a empty file
      ansible.builtin.file:
        path: /tmp/1.txt
        state: touch

Preview

Lets Use Ansible to deploy a Java application on Tomcat server

  • Manual Steps
sudo apt update
sudo apt install openjdk-8-jdk -y
sudo apt install tomcat9 -y
wget https://referenceapplicationskhaja.s3.us-west-2.amazonaws.com/gameoflife.war
sudo cp gameoflife.war /var/lib/tomcat9/webapps/
sudo systemctl restart tomcat9.service
  • Today lets install java using Ansible Playbook
  • For updating and installing java Refer Here
  • Created the ansible playbook Refer Here for the playbook
    Preview

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Animated Social Media Icons by Acurax Wordpress Development Company

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube