practical 2
Check if git
package is installed on web2
. Create a file /tmp/is_git_installed.txt
, file's content should be based on the condition:
If git is installed, print its installed version to the file and if git is absent, content must be: Oops, git is missing
Write a playbook at /home/thor/playbooks/check_if_missing.yml
and use the inventory file /home/thor/playbooks/inventory
Note: web2
is a ubuntu
host.
===============================================
---
- hosts: web2
gather_facts: true
become: yes
tasks:
- shell: dpkg -i git
register: check_if_git_installed
ignore_errors: yes
- debug: var=check_if_git_installed
- shell: echo 'oops, git is missing' > /tmp/is_git_installed.txt
when: check_if_git_installed != 0
- shell: git --version > /tmp/is_git_insta
Comments
Post a Comment