File: //lib/python3.9/site-packages/ansible/plugins/inventory/__pycache__/toml.cpython-39.pyc
a
�)g�% � @ s� d dl mZmZmZ eZdZdZd dlZd dl Z
d dlmZm
Z
d dlmZ d dlmZmZmZ d dlmZmZmZ d d lmZmZ d d
lmZmZ d dlmZ d dl m!Z! d d
l"m#Z#m$Z$ dZ%zd dl&Z&dZ%W n e'y� Y n0 dZ(zd dl)Z)dZ(W n e'�y Y n0 dZ*zd dl+Z+dZ*W n: e'�y\ zd dl,Z+dZ*W n e'�yV Y n0 Y n0 e!� Z-e%�r�e.e&d��r�G dd� de&j/�Z0ee&j1e0� d�Z2ndd� Z2e%�r�e&j3Z4e&j5Z6ne*�r�e+j3Z4e+j6Z6dd� Z7G dd� de�Z8dS )� )�absolute_import�division�print_functionaP
name: toml
version_added: "2.8"
short_description: Uses a specific TOML file as an inventory source.
description:
- TOML based inventory format
- File MUST have a valid '.toml' file extension
notes:
- >
Requires one of the following python libraries: 'toml', 'tomli', or 'tomllib'
a� # fmt: toml
# Example 1
[all.vars]
has_java = false
[web]
children = [
"apache",
"nginx"
]
vars = { http_port = 8080, myvar = 23 }
[web.hosts]
host1 = {}
host2 = { ansible_port = 222 }
[apache.hosts]
tomcat1 = {}
tomcat2 = { myvar = 34 }
tomcat3 = { mysecret = "03#pa33w0rd" }
[nginx.hosts]
jenkins1 = {}
[nginx.vars]
has_java = true
# Example 2
[all.vars]
has_java = false
[web]
children = [
"apache",
"nginx"
]
[web.vars]
http_port = 8080
myvar = 23
[web.hosts.host1]
[web.hosts.host2]
ansible_port = 222
[apache.hosts.tomcat1]
[apache.hosts.tomcat2]
myvar = 34
[apache.hosts.tomcat3]
mysecret = "03#pa33w0rd"
[nginx.hosts.jenkins1]
[nginx.vars]
has_java = true
# Example 3
[ungrouped.hosts]
host1 = {}
host2 = { ansible_host = "127.0.0.1", ansible_port = 44 }
host3 = { ansible_host = "127.0.0.1", ansible_port = 45 }
[g1.hosts]
host4 = {}
[g2.hosts]
host4 = {}
N)�MutableMapping�MutableSequence)�partial)�AnsibleFileNotFound�AnsibleParserError�AnsibleRuntimeError)�to_bytes� to_native�to_text)�string_types� text_type)�AnsibleSequence�AnsibleUnicode)�BaseFileInventoryPlugin)�Display)�AnsibleUnsafeBytes�AnsibleUnsafeTextFT�TomlEncoderc s e Zd Z� fdd�Z� ZS )�AnsibleTomlEncoderc sV t t| �j|i |�� | j�t| j�t�t| j�t �t
| j�t �t| j�t �i� d S �N)�superr �__init__Z
dump_funcs�updater �get�listr �strr r )�self�args�kwargs�� __class__� �B/usr/lib/python3.9/site-packages/ansible/plugins/inventory/toml.pyr � s �zAnsibleTomlEncoder.__init__)�__name__�
__module__�__qualname__r �
__classcell__r$ r$ r"