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 Tutorial: Data Types, Lists, Dictionaries, and Practical Examples

Image
Hello DevOps enthusiasts! Many repetitive and time-consuming tasks in our daily work can be automated effectively using tools like Ansible . However, to build powerful and reusable automation, one of the most important concepts you need to master is variables . Variables allow you to write flexible playbooks that can adapt to different environments, applications, and operating systems without hardcoding values. In this article, we'll explore how variables work in Ansible and learn how to use different data types, lists, and dictionaries through practical examples. Ansible Variables Overview What We'll Learn By the end of this article, you will be able to: Understand variable fundamentals in Ansible Work with common Ansible data types Create and access list variables Manipulate list elements Create and use dictionary variables Access dictionary keys and values Debug variable types using type_debug Build more reusable and maintainable playbooks Why are Variables important  Imagi...