Wednesday, November 27, 2019

variables and facts of Playbooks

variables and facts:

Facts are the data about individual hosts and they populate variables with these data.
setup module takes care of this to fetch data.

Facts:
---
CPU type
OS Family
RAM amount
IP Address
CPU Cores

ansible ubuntu -m setup
ansible ubuntu -m setup -a "filter=*family*"

will show the data(key/value pairs which can be used as variables) as output



---

- hosts: ubuntu
  vars: 
   - var1: cool stuff here
   - var2: cool stuff here
     yum: name=vsftpd state=latest
  tasks:
   - name: echo stuff
     shell: echo " {{ var1 }} is var1, var2 is {{ var2 }}" > /home/user1/Desktop/{{ansible_os_family}}.txt




No comments:

Post a Comment