ansible

Ansible: Azure Resource Manager inventory plugin (part 2)

Continuing the ARM inventory plugin post. Follow below some useful settings to help you to generate a good dynamic inventory. Working with group conditionalconditional_groups: # since this will be true for every host, every host sourced from this inventory plugin config will be in the # group 'all' all: true # if the VM's "name" variable contains "test", it will be placed in the 'test' group. test: "'test' in name" # if the VM's "name" variable contains "dev", it will be placed in…

Keep reading

Ansible: string vault

Ansible Vault is a feature of ansible that allows you to keep sensitive data such as passwords or keys in encrypted files, rather than as plaintext in playbooks or roles. These vault files can then be distributed or placed in source control. The ansible-vault encrypt_string command will encrypt and format a provided string into a format that can be included in ansible-playbook YAML files. Passing vault key file.ansible-vault encrypt_string --vault-password-file=.vault --name 'some_easy_label' ‘secret’ Without vault key file.ansible-vault encrypt_string --name 'some_easy_label'…

Keep reading

Ansible: How-to install Azure Resource Manager inventory plugin (part 1)

IntroductionThis plugin allows you to work with dynamic inventory on Azure.Features Support VMSSConditional groups based on the name of the instances.Key group tags creationMultiples authentication methods wayInstallation Install azure cli https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest Install azure inventory plugin pip install 'ansible[azure]' Setup Create a new file called azure_rm.yml --- plugin: azure_rm auth_source: auto # Include VMSS. include_vmss_resource_groups: - '*'Setup Azure subscription settingsAzure cli az login az account set --subscription <subscription_name>…

Keep reading

Molecule: Working with inventory

In this post, I will explain how to enable and manage inventory on the molecule. This is could be interesting when you have to parse some inventory within the role. 1) Edit the file: molecule/default/playbook.yml --- - name: Converge hosts: all roles: - role: my_role 2) Add the inventory configuration into the file molecule/default/molecule.yml --- dependency: name: galaxy driver: name: docker lint: name: yamllint platforms: - name: instance image: centos:7 provisioner: name: ansible lint: name: ansible-lint inventory: links: hosts: inventory.yml verifier:…

Keep reading

Molecule: Enabling roles dependencies

Molecule supports roles dependencies, however, we need to define the role-file parameter into the molecule.yml file to fetch the roles automatically. 1) Change the molecule.yml file according to the sample below. dependency: name: galaxy options: role-file: ${MOLECULE_SCENARIO_DIRECTORY}/requirements.yml2) Create a file called requirements.yml within molecule folder. --- # sample for springboot role. - src: git@gitlab.yourdomain.com:/ansible/roles/springboot.git scm: git3) Add the role into the playbook.yml file. - name: Converge hosts: all roles: - role: springboot - role: myrole…

Keep reading