Created
October 9, 2021 06:13
-
-
Save takuan-osho/04b5fd7d0f389326d1ed025b38aa2532 to your computer and use it in GitHub Desktop.
sample codes of ansible role argument validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[defaults] | |
stdout_callback = debug | |
stderr_callback = debug |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[default] | |
localhost ansible_connection=local ansible_python_interpreter=${HOME}/.pyenv/shims/python3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
argument_specs: | |
main: | |
short_description: Sample role argument validation. | |
options: | |
required_vars: | |
type: "bool" | |
required: true | |
description: "This variable is required" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- 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