Ansible Playbook for Maven Installation OS family Jar download

preview_player
Показать описание
In this videos will discussed about ansible playbook for maven installation os family jar downloaded
---
- hosts: nodes
tasks:
- name: download apche maven
get_url:
dest: /opt
mode: '0755'
- name: extract the tar file
unarchive:
dest: /opt
remote_src: True
- name: Removing tart file
file:
state: absent
- name: Renaming a file
command: mv /opt/apache-maven-3.6.3 /opt/maven
- name: set environment variable
lineinfile: dest=/root/.bashrc line='export PATH=$PATH:/opt/maven/bin' insertafter='EOF' regexp='export PATH=\$PATH:/opt/maven/bin' state=present
- name: source the bashrc file
shell: source /root/.bashrc
remote_user: root

ansible -i mvninventorys -m ping mvnnodes

===========
ansible -i /home/inventory all
---
- hosts: allnodes
gather_facts: yes
tasks:
- name: get ansible-distributions
debug:
msg: "{{ ansible_distribution }}"
- name: get ansible-distribution version
debug:
msg: "{{ ansible_distribution_version }}"
- name: get ansible-distribution major version
debug:
msg: "{{ ansible_distribution_major_version }}"

ex:2
---
- hosts: nodes
gather_facts: True
tasks:
- name: Install apache webserver on rhel 8
yum:
name: httpd
state: present
when: ansible_facts['distribution'] == "RedHat"
- name: Install apache 2 on ubuntu 20.08
apt:
name: apche2
state: present
when: ansible_os_family == "Debian"
- name: get os family
debug:
msg: "{{ ansible_os_family }}"

=================================
ansible -m shell -a "echo {{ ansible_hostname }}" nodes
ansible -m shell -a "echo {{ inventoryj_hostname }}" nodes

---
- hots: rhlgroup
tasks:
- name: check java rpm is already there or not
yum:
list: java-1.8.0-openjdk-devel
register: java_output_check
- name: print java_output_check
debug:
msg: "{{ java_output_check }}"
- name: install java only if is already not there
yum:
name: java-1.8.0-openjdk-devel
state: present

#################################
i want to download jar/war file from central repository using playbook

yum install python2-pip -y
pip install lxml

---
- hosts: localhost
tasks:
- name: download mysql jar
maven_artifact:
group_id: mysql
artifact_id: mysql-connector-java
version: '8.0.23'
dest: /opt
============================
---
- hosts: localhost
tasks:
- name: download mysql jar in tmp folder
get_url:
dest: /opt
mod: '0755'
Рекомендации по теме