Skip to content

Instantly share code, notes, and snippets.

@takuan-osho
Created October 9, 2021 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuan-osho/04b5fd7d0f389326d1ed025b38aa2532 to your computer and use it in GitHub Desktop.
Save takuan-osho/04b5fd7d0f389326d1ed025b38aa2532 to your computer and use it in GitHub Desktop.
sample codes of ansible role argument validation
[defaults]
stdout_callback = debug
stderr_callback = debug
[default]
localhost ansible_connection=local ansible_python_interpreter=${HOME}/.pyenv/shims/python3
argument_specs:
main:
short_description: Sample role argument validation.
options:
required_vars:
type: "bool"
required: true
description: "This variable is required"
- name: Echo localhost's hostname
ansible.builtin.shell: echo {{ inventory_hostname }}
register: result
- name: The result is supposed to be "localhost"
debug:
var: result.stdout
- hosts: localhost
gather_facts: no
roles:
- role: sample
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment