??????????????
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 173
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 174
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 175
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 176
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 177
Warning: Cannot modify header information - headers already sent by (output started at /home/mybf1/public_html/mentol.bf1.my/SS1.php:4) in /home/mybf1/public_html/mentol.bf1.my/SS1.php on line 178
ó
àUdac @` s” d d l m Z m Z m Z e Z d Z d Z d d l Z d d l m
Z
d d l m Z
d d l m Z d d l m Z d e f d
„ ƒ YZ d S( i ( t absolute_importt divisiont print_functions"
name: generator
plugin_type: inventory
version_added: "2.6"
short_description: Uses Jinja2 to construct hosts and groups from patterns
description:
- Uses a YAML configuration file with a valid YAML or C(.config) extension to define var expressions and group conditionals
- Create a template pattern that describes each host, and then use independent configuration layers
- Every element of every layer is combined to create a host for every layer combination
- Parent groups can be defined with reference to hosts and other groups using the same template variables
options:
plugin:
description: token that ensures this is a source file for the 'generator' plugin.
required: True
choices: ['generator']
hosts:
description:
- The C(name) key is a template used to generate
hostnames based on the C(layers) option. Each variable in the name is expanded to create a
cartesian product of all possible layer combinations.
- The C(parents) are a list of parent groups that the host belongs to. Each C(parent) item
contains a C(name) key, again expanded from the template, and an optional C(parents) key
that lists its parents.
- Parents can also contain C(vars), which is a dictionary of vars that
is then always set for that variable. This can provide easy access to the group name. E.g
set an C(application) variable that is set to the value of the C(application) layer name.
layers:
description:
- A dictionary of layers, with the key being the layer name, used as a variable name in the C(host)
C(name) and C(parents) keys. Each layer value is a list of possible values for that layer.
sÿ
# inventory.config file in YAML format
plugin: generator
strict: False
hosts:
name: "{{ operation }}-{{ application }}-{{ environment }}-runner"
parents:
- name: "{{ operation }}-{{ application }}-{{ environment }}"
parents:
- name: "{{ operation }}-{{ application }}"
parents:
- name: "{{ operation }}"
- name: "{{ application }}"
- name: "{{ application }}-{{ environment }}"
parents:
- name: "{{ application }}"
vars:
application: "{{ application }}"
- name: "{{ environment }}"
vars:
environment: "{{ environment }}"
- name: runner
layers:
operation:
- build
- launch
environment:
- dev
- test
- prod
application:
- web
- api
N( t product( t constants( t AnsibleParserError( t BaseInventoryPlugint InventoryModulec B` sD e Z d Z d Z d „ Z d „ Z d „ Z d „ Z e d „ Z RS( s> constructs groups and vars using Jinja2 template expressions t generatorc C` s t t | ƒ j ƒ d S( N( t superR t __init__( t self( ( sG /usr/lib/python2.7/site-packages/ansible/plugins/inventory/generator.pyR
X s c C` sc t } t t | ƒ j | ƒ r_ t j j | ƒ \ } } | sS | d g t j k r_ t } q_ n | S( Ns .config(
t FalseR R t verify_filet ost patht splitextt Ct YAML_FILENAME_EXTENSIONSt True( R R t validt file_namet ext( ( sG /usr/lib/python2.7/site-packages/ansible/plugins/inventory/generator.pyR
\ s c C` s | | j _ | j j | ƒ S( N( t templart available_variablest do_template( R t patternt variables( ( sG /usr/lib/python2.7/site-packages/ansible/plugins/inventory/generator.pyt templateg s c
C` s xù | D]ñ } y | j | d | ƒ } Wn+ t t f k
rT t d | d ƒ ‚ n X| | j k rt | j | ƒ n | j | } xB | j d i ƒ j ƒ D]( \ } } | j | | j | | ƒ ƒ qš W| j | | ƒ | j
| | | j d g ƒ | ƒ q Wd S( Nt names, Element %s has a parent with no name elementt varst parents( R t AttributeErrort
ValueErrorR t groupst add_groupt gett itemst set_variablet add_childt add_parents(
R t inventoryt childR t
template_varst parentt groupnamet groupt kt v( ( sG /usr/lib/python2.7/site-packages/ansible/plugins/inventory/generator.pyR( k s
% c C` sç t t | ƒ j | | | d | ƒ| j | ƒ } t | d j ƒ Œ } x™ | D]‘ } t ƒ } x2 t | d j ƒ ƒ D] \ } }
| | | |