

Generally speaking, this is not the best way to define variables that describe your system policy. The YAML inventory plugin processes variable values consistently and correctly. Do not rely on types set in INI inventories when consuming variables.Ĭonsider using YAML format for inventory sources to avoid confusion on the actual type of a variable. If a variable value set in an INI inventory must be a certain type (for example, a string or a boolean value), always specify the type with a filter in your task. Unlike host lines, :vars sections accept only a single entry per line, so everything after the = must be the value for the entry. For example var=FALSE would create a string equal to ‘FALSE’. When declared in a :vars section, INI values are interpreted as strings. See the Python shlex parsing rules for details. Values that contain whitespace can be quoted (single or double). Therefore they need a way to indicate that a space is part of a value rather than a separator. Host lines accept multiple key=value parameters per line. When declared inline with the host, INI values are interpreted as Python literal structures (strings, numbers, tuples, lists, dicts, booleans, None). Values passed in the INI format using the key=value syntax are interpreted differently depending on where they are declared: When - The development stage, to avoid testing on production resources (for example, prod, test).Įxtending the previous YAML inventory to include what, when, and where would look like: Where - A datacenter or region, to talk to local DNS, storage, and so on (for example, east, west). What - An application, stack or microservice (for example, database servers, web servers, and so on). For example a production webserver in a datacenter in Atlanta might be included in groups called and and. You can (and probably will) put each host in more than one group. Though all and ungrouped are always present, they can be implicit and not appear in group listings like group_names. The ungrouped group contains all hosts that don’t have another group aside from all.Įvery host will always belong to at least 2 groups ( all and ungrouped or all and some other group). There are two default groups: all and ungrouped. Controlling how Ansible behaves: precedence rulesĪll : hosts : : children : webservers : hosts : : : dbservers : hosts : : : : Default groups .Virtualization and Containerization Guides.Controlling playbook execution: strategies and more.Executing playbooks for troubleshooting.Validating tasks: check mode and diff mode.Discovering variables: facts and magic variables.Connecting to hosts: behavioral inventory parameters.Assigning a variable to many machines: group variables.Assigning a variable to one machine: host variables.Inventory basics: formats, hosts, and groups.Working with language-specific version managers.Controlling where tasks run: delegation and local actions.Understanding privilege escalation: become.
