Showing posts with label YAML. Show all posts
Showing posts with label YAML. Show all posts

Thursday, 4 July 2024

Azure tutorials with Terraform and Packer and Ansible ..

 Here are some links to be used to build and deploy Packer Image Automated Build, Provisioned with Ansible and Deployed into infrastructure with Terraform. 


Links list; 

- Microsoft Tutorial to Implement as tutorial and publish as Video Tutorial - https://cloudblogs.microsoft.com/opensource/2018/05/23/immutable-infrastructure-azure-vsts-terraform-packer-ansible/  ( This article my have few bugs and incompatibilities as it was done ages ago and the application has since moved into more advanced versions ) 


- Here - Creating VM Images with Packer in Microsoft Azure - https://medium.com/slalom-build/azure-packer-592c4dc0e23a  

- This tutorial is more oriented for Amazon AWS  instead of Azure - https://devopscube.com/packer-tutorial-for-beginners/   

- This another tutorial buils Terraform and Packer image build automation for Amazon AWS - https://www.bogotobogo.com/DevOps/Terraform/Terraform-state-tfstate-import.php  





4 – Videos to be implemented on Jobudo DevTeam Channel – Or create another Playlist on my existent TDLM Channel ..


I was glad to help! If you still have any questions, then be sure to contact us.
✅ Be sure to subscribe to our official social network:

Friday, 5 April 2024

In ansible what is the best way to get dict object to print out ?

There are several ways to print out a dictionary object in Ansible, depending on your desired level of detail and formatting:

1. Using debug Module:

This is the simplest way to print the entire dictionary, including keys and values.

YAML
- debug:
    var: my_dict

2. Using Jinja2 Template Filters:

  • json_encode filter: Converts the dictionary to a JSON string for a structured representation.
YAML
- debug:
    msg: "Dictionary as JSON: {{ my_dict | json_encode }}"
  • to_yaml filter (if using the yaml collection): Converts the dictionary to a YAML string.
YAML
- debug:
    msg: "Dictionary as YAML: {{ my_dict | to_yaml }}"
  • Custom filters: Create custom filters to format the output according to your specific needs.

3. Looping through the Dictionary:

For a more controlled output, iterate through the dictionary using a loop and print individual key-value pairs.

YAML
- debug:
    msg: "Key: {{ item.key }}, Value: {{ item.value }}"
  loop: "{{ my_dict }}"
  vars:
    item: key_value  # Adjust variable name if needed

4. Using dict Lookup Plugin:

The dict lookup plugin allows you to access specific values within the dictionary:

YAML
- debug:
    msg: "Value of key 'foo': {{ lookup('dict', my_dict.foo) }}"

Choosing the Best Method:

  • Use debug for quick inspection of the entire dictionary.
  • Use Jinja2 filters for structured output (JSON or YAML) or with custom formatting.
  • Use loop for controlled output and accessing specific key-value pairs.
  • Use dict lookup plugin for retrieving specific values within the dictionary.

Just to mention if you are looking for your next Techie Job in UK - Check this out 

How to check for open ports on Linux

Checking for open ports is among the first steps to secure your device. Listening services may be the entrance for attackers who may exploit...