Posts

Showing posts with the label ansible facts

Ansible Facts - Customizations

Image
Hey DevOps Team, In this post I would like to give you the knowledge on the special feature about Ansible Facts and we can also customize these facts as global variables to use in multiple playbooks. What is ansible facts?  Ansible facts are just simple variables that are automatically discovered by ansible on a managed nodes. such as system information disk info, os info, package info IP Network and many more ... Why we manage facts? Default these facts will be automatically collected exclusively we need to disable some times. - multiple play in a playbook How can we use facts? we want to run only when enough memory is available on the target machine then install the package. That is the smartest way to do the automation! --- # File : hello.yaml - name: Facts example hosts: "{{targets|default('localhost')}}" tasks: - name: prints details debug: msg: "Hello this machine have {{ ansible_memory_mb['real'] }}" whe...

Ansible variables, Lists, Dictionaries

Image
 There are many boring tasks in your daily job which can be automated easily if you know some of the tools like here, Ansible. Let's explore more on how to use the variables in the playbooks. In this post we will be covering : Basic datatypes List variables and using them Dictionary variable and accessing them Variables and Datatypes in Ansible In Ansible variables can be defined under global tasks or they can be defined at local to a task level. support all the Python supported datatypes. --- # Filename: varibles_datatypes.yml - name: varibles in ansible hosts: localhost gather_facts: false vars: a: "Vybhava Technologies" b: yes n: 100 m: 500.99 tasks: - debug: msg: - "a= {{ a }} a type: {{ a |type_debug }}" - "b= {{ b }} b type: {{ b |type_debug }}" - "n= {{ n }} n type: {{ n |type_debug }}" - "m= {{ m }} m type: {{ m |type_debug }}" The...