Ansible Module set fact: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 9: Line 9:


=Overview=
=Overview=
This module allows setting new variables.
Variables are set on a host-by-host basis just like facts discovered by the setup module.
These variables will be available to subsequent plays during an ansible-playbook run.
Set cacheable to yes to save variables across executions using a fact cache. Variables created with set_fact have different precedence depending on whether they are or are not cached.
Per the standard Ansible variable precedence rules, many other types of variables have a higher priority, so this value may be overridden.
This module is also supported for Windows targets.


<syntaxhighlight lang='yaml'>
<syntaxhighlight lang='yaml'>

Revision as of 00:21, 30 December 2020

External

Internal

Overview

This module allows setting new variables.

Variables are set on a host-by-host basis just like facts discovered by the setup module.

These variables will be available to subsequent plays during an ansible-playbook run.

Set cacheable to yes to save variables across executions using a fact cache. Variables created with set_fact have different precedence depending on whether they are or are not cached.

Per the standard Ansible variable precedence rules, many other types of variables have a higher priority, so this value may be overridden.

This module is also supported for Windows targets.

- name: Set bashrc.d directory path
  set_fact:
    bashrc_d: "{{ ansible_env.HOME }}/.bashrc.d"