Showing posts with label ansible. Show all posts
Showing posts with label ansible. Show all posts

Thursday, January 25, 2018

Ansible and Jinja2 template rendering


In this example an ansible playbook has some variables defined. These variables are then rendered by Jinja. 

The jinja template file here is jinjafile.j2  that gets saved after the rendering to the text file /tmp/ansible.all

The Jinja2 template file here looks clumsy. but please note that the multiline comment in Jinja2 is as {# .... #}. These are used in order as here in this template to inline explain the Jinja syntax. 

Once the playbook is in place and the jinja template file with the name of  jinjafile.j2 with the contents as in the mention, you can run the playbook and then see the contents of the rendered file /tnp/ansible.all

The Ansible playbook looks like 


---
- name: JinjAs
  hosts: localhost

  vars:

    foo: { "bar": 200, "abc": 1000, "sujit": 20000 }
    list1: [ 1, 2, 3 ]
    list2: [ 3, 4, 5 ]
    list3: { "x": "a", "y": "b" }

    production:
      - { name: "server1", ip: "1.1.1.1" }
      - { name: "server2", ip: "2.2.2.2" }

  tasks:
    - name: jinja render save to a file
      template: src=jinjafile.j2 dest=/tmp/ansible.all force=true


Please note that the actual JINJA syntax is highlighted in Blue and the remaining are the explanations of the syntax exampe.

The corresponding Jinja2 template file looks like

{#
## Select a random output from the list
## for selection of a random value from the list ["a", "b", "c"]
## the jinja syntax for the same is
##{{[ "a", "b", "c" ] | random }}
##
## The result is "b"
##

{{[ "a", "b", "c" ] | random }}

{#
## print the entire list here list1 is a list variable as list1 = [ 1, 2, 3 ]
## ## the jinja syntax for the same is
##
##{{ list1 }}
##
## The result is [1, 2, 3]
##
#}
{{ list1 }}


{#
## print each of the elements in a simple list
## here the list given is as list1 = [ 1, 2, 3 ]
## ## the jinja syntax for the same is
##
#}

{#
##{% for item in list1 %}
##{{ item }}
##{% endfor %}
##
## The result is
1
2
3
##
#}

{% for item in list1 %}
{{ item }}
{% endfor %}

{#
## printing of each of the element of a simple list variable where list1 is a variable like list1 = [ 1, 2, 3 ]
## This will union the 2 lists
## to union 2 lists where list1 = [ 1, 2, 3] and list2 = [ 3, 4, 5 ]
## the jinja syntax for the same is
##
##
##{{ list1 | union(list2) }}
## The result is [1, 2, 3, 4, 5]
##
#}

{{ list1 | union(list2) }}



{#
## This will show the length of the list
## This shows the length of the list list1 where list1 = [ 1, 2, 3 ]
## the jinja syntax for the same is
##
##
##{{ list1 | length }}
## The result is 3
##
#}
{{ list1 | length }}

{#
## This is to extract the elements at the list indexes of 0 and 1 from the list list11 where list1 = [ 1, 2, 3 ]
## extraction of the list index elements at the index of 0 and 1 from list list1 = [ 1, 2, 3 ]
## the jinja syntax for the same is
##
##
##{{ [0,2]  | map('extract',list1)| list }}
## The result is [1, 3]
##
#}
{{ [0,2]  | map('extract',list1)| list }}

{#
## This is to extract the values of the keys 'x' and 'y' from the dictionary { "x": 22 , "y" 44 }
## the jinja syntax for the same is
##
##{{ ['x', 'y'] | map('extract', { 'x': 22, 'y': 44 }) | list }}
##
## The result is [22, 44]
##
#}
{{ ['x', 'y'] | map('extract', { 'x': 22, 'y': 44 }) | list }}

{#
## This is again an example to know the number of elements but this time the object is a dict where
## the dict foo is as foo: { "bar": 200, "abc": 1000, "sujit": 20000 }
##
## ## the jinja syntax for the same is
##
##The lengh of the variable or the number of elements in the variable foo is
##{{ foo | length }}
##
##
## The result is 3
##
#}
{{ foo | length }}

{#
## for the dict variable foo where foo is foo: { "bar": 200, "abc": 1000, "sujit": 20000 }
## this prints each of the key and the value pairs iterating over all the elements of the dict
## notice the use of 'iteritems' here
##
## ## the jinja syntax for the same is
##
##
##
##{% for key, value  in foo.iteritems() %}
##{{ key }} : "{{ value }}"
##{% endfor %}
##
##
## The result is
##
sujit : "20000"
abc : "1000"
bar : "200"
#}
{% for key, value  in foo.iteritems() %}
{{ key }} : "{{ value }}"
{% endfor %}

{#
## for the variable foo which is a dict as foo: { "bar": 200, "abc": 1000, "sujit": 20000 }
## with the multiple elements
## this prints the value of the element having key as "bar"
## ## the jinja syntax for the same is
##
##
##{{ foo.bar }}
##
## The result is 200
##
##
##
#}
{{ foo.bar }}

{#
## this is the same as the example previous
##
##
## the jinja syntax for the same is
##
##{{ foo['bar'] }}
##
##
## The result is 200
##
#}
{{ foo['bar'] }}


{#
## This is for the example of evaluating the value of foo.bar is equal to 100 or not where foo is a dict as foo: { "bar": 200, "abc": 1000, "sujit": 20000 }
## the jinja syntax for the same is
##
##{% if foo.bar == 100 %}
##value is 100
##{% else %}
##value is not 100
##{% endif %}
##
## The result is "value is not 100"
##
#}
{% if foo.bar == 100 %}
value is 100
{% else %}
value is not 100
{% endif %}

{#
## See the length of or the list variable production where each of the entity in the variable production is a dict in itself
## Here the production variable looks like below.
## the same "production" variable has also been used in the subsequent examples
##    production:
##      - { name: "server1", ip: "1.1.1.1" }
##      - { name: "server2", ip: "2.2.2.2" }
## the jinja syntax for the same is
##
##
##{{ production | length }}
##
##
## The result is 2
##
#}
{{ production | length }}

{#
## for the production variable above that is a list of dictionaries, the list shows the items of the list
## The result will be a list of dictionaries
##
##
## the jinja syntax for the same is
##
##
##{{ production | list }}
##
## The result is [{u'ip': u'1.1.1.1', u'name': u'server1'}, {u'ip': u'2.2.2.2', u'name': u'server2'}]
##
#}
{{ production | list }}

{#
## also the way to iterate through the elements of the variable production as production is a list of dicts
##
## the jinja syntax for the same is
##
##{% for item in production %}
##      {{ item }}
##{% endfor %}
##
## The result is 
        {u'ip': u'1.1.1.1', u'name': u'server1'}
        {u'ip': u'2.2.2.2', u'name': u'server2'}

##
#}
{% for item in production %}
        {{ item }}
{% endfor %}

{#
## for the list of dictionaries values variable production this iterates to each dict element
## then this iterates through each of the elements in the dict and prints the key value pairs.
##
##
## the jinja syntax for the same is
##
##{% for item in production|list %}
##{% for key, value in item.iteritems() %}
##{{key}}: "{{value}}"
##{% endfor %}
##{% endfor %}
##
## The result is
ip: "1.1.1.1"
name: "server1"
ip: "2.2.2.2"
name: "server2"

##
#}

{% for item in production|list %}
{% for key, value in item.iteritems() %}
{{key}}: "{{value}}"
{% endfor %}
{% endfor %}

Ansible with_dict variables


Here is another example of how the referencing can take place. As can be seen "vsports" being pulled in the variable of ports


---
- name: test variables
  hosts: localhost
  gather_facts: no

  vars:
    pools: [ "pool1", "pool2" ]
    vsports: [ "8443" , "443", "8089", "8184" ]
    clusters:
      cluster1:
        server1:
          server_port: 8081
          service: apache
          pools:
            pool1:
              virtual_servers:
                - { name: "vs1", fq: "vs1.example.com", ports: "{{ vsports[0] }}" }
                - { name: "vs2", fq: "vs2.example.com", ports: "{{ vsports[1] }}" }

            pool2:
              virtual_servers:
                - { name: "vs3", fq: "vs3.example.com", ports: "{{ vsports[2] }}" }
                - { name: "vs4", fq: "vs4.example.com", ports: "{{ vsports[3] }}" }

  tasks:

    - name: see the variables for server names
      debug: msg="{{ item }}"
      with_dict: "{{ clusters }}"

The Run of the playbook as seen here.

[root@ansible testplaybooks]# ansible-playbook 6play.yaml

PLAY [test variables] **************************************************************************************************************************

TASK [see the variables for server names] ******************************************************************************************************
ok: [localhost] => (item={'value': {u'server1': {u'pools': {u'pool2': {u'virtual_servers': [{u'fq': u'vs3.example.com', u'name': u'vs3', u'ports': u'8089'}, {u'fq': u'vs4.example.com', u'name': u'vs4', u'ports': u'8184'}]}, u'pool1': {u'virtual_servers': [{u'fq': u'vs1.example.com', u'name': u'vs1', u'ports': u'8443'}, {u'fq': u'vs2.example.com', u'name': u'vs2', u'ports': u'443'}]}}, u'service': u'apache', u'server_port': 8081}}, 'key': u'cluster1'}) => {
    "changed": false,
    "item": {
        "key": "cluster1",
        "value": {
            "server1": {
                "pools": {
                    "pool1": {
                        "virtual_servers": [
                            {
                                "fq": "vs1.example.com",
                                "name": "vs1",
                                "ports": "8443"
                            },
                            {
                                "fq": "vs2.example.com",
                                "name": "vs2",
                                "ports": "443"
                            }
                        ]
                    },
                    "pool2": {
                        "virtual_servers": [
                            {
                                "fq": "vs3.example.com",
                                "name": "vs3",
                                "ports": "8089"
                            },
                            {
                                "fq": "vs4.example.com",
                                "name": "vs4",
                                "ports": "8184"
                            }
                        ]
                    }
                },
                "server_port": 8081,
                "service": "apache"
            }
        }
    },
    "msg": {
        "key": "cluster1",
        "value": {
            "server1": {
                "pools": {
                    "pool1": {
                        "virtual_servers": [
                            {
                                "fq": "vs1.example.com",
                                "name": "vs1",
                                "ports": "8443"
                            },
                            {
                                "fq": "vs2.example.com",
                                "name": "vs2",
                                "ports": "443"
                            }
                        ]
                    },
                    "pool2": {
                        "virtual_servers": [
                            {
                                "fq": "vs3.example.com",
                                "name": "vs3",
                                "ports": "8089"
                            },
                            {
                                "fq": "vs4.example.com",
                                "name": "vs4",
                                "ports": "8184"
                            }
                        ]
                    }
                },
                "server_port": 8081,
                "service": "apache"
            }
        }
    }
}

PLAY RECAP *************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=0

Wednesday, January 24, 2018

Ansible with_dict to iterate over items in a dictionary type variable

Iterating the nested variables using "with_dict" provides great flexibility of addressing the dictionary type variables. Here is a simple playbook to illustrate that.

Here the variables are defined as normally using vars in the playbook play.  The variable "production" as seen in the playbook  is a YAML dictionary type variable.


  • The way the three servers 'server1', 'server2' and 'server3' are defined are the same even though they are written not in the same manne
  • YAML reads [...] as a list and { ... } as a dictionary as a key-value pairs.


The task at the and of the playbook using the keyword "with_dict" and variable as " {{ production }}" reads through all the member variables that are key value pairs.

In the last task that is a debug task you can also see by replacing the with_dict with the value of  "{{production.server1}} and see the results. The same works still as even the variable "server1" is a dictionary.

---
- name: test playbook
  hosts: localhost
  become: true
  become_user: root

  vars:
    production:
      server1:
        name: "server1"
        ip: "192.1.1.1"
        port: 443
        pools:
          - pool1
          - pool2
        vss:
          - vs1
          - vs2

      server2:
        name: "server2"
        ip: "192.168.1.2"
        port: 443
        pools: [ "pool1", "pool2" ]
        vss: [ "vs1", "vs2" ]

      server3: { name: "server3", ip: "192.168.100.200", port: 443, pools: [ "pool1", "pool2" ], vss: [ "vs1", "vs2" ] }


  tasks:
    - name: see the variables for production
      debug: msg="{{item.key}}"
      with_dict: "{{ production }}"

----

As the play book is run the following is observed as to how Ansible reads through each of the key-value pairs in the dictionary and the sub-values also


[root@ansible testplaybooks]# ansible-playbook 2play.yaml

PLAY [test playbook] *************************************************************************************************************************************************************************

TASK [Gathering Facts] ***********************************************************************************************************************************************************************
ok: [localhost]

TASK [see the variables for production] ******************************************************************************************************************************************************
ok: [localhost] => (item={'value': {u'pools': [u'pool1', u'pool2'], u'ip': u'192.1.1.1', u'vss': [u'vs1', u'vs2'], u'name': u'server1', u'port': 443}, 'key': u'server1'}) => {
    "changed": false,
    "item": {
        "key": "server1",
        "value": {
            "ip": "192.1.1.1",
            "name": "server1",
            "pools": [
                "pool1",
                "pool2"
            ],
            "port": 443,
            "vss": [
                "vs1",
                "vs2"
            ]
        }
    },
    "msg": "server1"
}
ok: [localhost] => (item={'value': {u'pools': [u'pool1', u'pool2'], u'ip': u'192.168.1.2', u'vss': [u'vs1', u'vs2'], u'name': u'server2', u'port': 443}, 'key': u'server2'}) => {
    "changed": false,
    "item": {
        "key": "server2",
        "value": {
            "ip": "192.168.1.2",
            "name": "server2",
            "pools": [
                "pool1",
                "pool2"
            ],
            "port": 443,
            "vss": [
                "vs1",
                "vs2"
            ]
        }
    },
    "msg": "server2"
}
ok: [localhost] => (item={'value': {u'pools': [u'pool1', u'pool2'], u'ip': u'192.168.100.200', u'vss': [u'vs1', u'vs2'], u'name': u'server3', u'port': 443}, 'key': u'server3'}) => {
    "changed": false,
    "item": {
        "key": "server3",
        "value": {
            "ip": "192.168.100.200",
            "name": "server3",
            "pools": [
                "pool1",
                "pool2"
            ],
            "port": 443,
            "vss": [
                "vs1",
                "vs2"
            ]
        }
    },
    "msg": "server3"
}

PLAY RECAP ***********************************************************************************************************************************************************************************
localhost                  : ok=2    changed=0    unreachable=0    failed=0

Friday, June 9, 2017

Ansible Playbook with multiple lists in the variables with multiple with_items calls in the tasks example

Ansible Playbook with multiple lists in the variables with multiple with_items calls in the tasks

The sample playbook looks like this. This has four lists defined in the vars: section. 
First is the list of the packages to be installed name of the list being "packages" in the playbook.
Second list having name as "stopservice" is the list of the services to be stopped
Third list is the list of the services to be started also enabled with the name of the list being as "startservice"
As can be seen in the playbook the call to each of the items of a list is in the form of 

"{{item.name}}"
with_items  takes the values as
"{{packages}}" or "{{startservice}}" or "{{stopservice}}" as the name of the list



The fourth list is the list of the files to be got from a URL and to be copied to a certain location on the servers
The list name is "urls"
The name is the identifier
url is the URL wherefrom the file can be downloaded. 
dest is the location on the server on where the file has to be copied to while being received using the get_url module of ansible

here the important values to be passed to the get_url module are "url" and "dest"
the "url" and "dest" are different for each item in the list "urls"

The pairs of url and dest are passed to the get_url module as 

get_url:
  url: "{{item.url}}"
  dest: "{{item.dest}}"
with_items: "{{urls}}"

Also note the use of the "force" option of the get_url to ensure that the target file is overwritten when the contents at the source url change.

Here is the example playbook


[devops@ansible playbooks]$ cat firstplaybook.yml
---
- name: install packages
  hosts: all
  vars:
    - packages:
      - name: chrony
      - name: bash-completion
      - name: yum-utils
      - name: bind-utils
      - name: net-tools
      - name: ntp
      - name: firewalld
      - name: wget
      - name: curl
      - name: unzip

    - stopservice:
      - name: firewalld

    - startservice:
      - name: chronyd
      - name: ntpd

    - urls:
      - name: hosts
        url: http://ansible.lab.example.com/config/hosts
        dest: /etc/hosts
      - name: nsswitch.conf
        url: http://ansible.lab.example.com/config/nsswitch.conf
        dest: /etc/nsswitch.conf
      - name: profile
        url: http://ansible.lab.example.com/config/profile
        dest: /etc/profile
      - name: resolv.conf
        url: http://ansible.lab.example.com/config/resolv.conf
        dest: /etc/resolv.conf
      - name: selinuxconfig
        url: http://ansible.lab.example.com/config/selinuxconfig
        dest: /etc/selinux/config
      - name: yum.conf
        url: http://ansible.lab.example.com/config/yum.conf
        dest: /etc/yum.conf



  tasks:
    - name: install package
      yum:
        name: "{{item.name}}"
        state: latest
      with_items:
        - "{{packages}}"

    - name: stop the services
      service:
        state: stopped
        enabled: false
        name: "{{item.name}}"
      with_items:
        - "{{stopservice}}"

    - name: start and enable services
      service:
        name: "{{item.name}}"
        state: started
        enabled: true
      with_items:
        - "{{startservice}}"

    - name: copy configuration files from the URLs
      get_url:
        url: "{{item.url}}"
        dest: "{{item.dest}}"
        use_proxy: no
        force: yes
      with_items:
        - "{{urls}}"



[devops@ansible playbooks]$


----------------------------------

Run of the Playbook
----------------------------------


[devops@ansible playbooks]$ ansible-playbook firstplaybook.yml

PLAY [install packages] ********************************************************************************************

TASK [Gathering Facts] *********************************************************************************************
ok: [ansible.lab.example.com]
ok: [server2.lab.example.com]
ok: [server1.lab.example.com]
ok: [server3.lab.example.com]

TASK [install package] *********************************************************************************************
ok: [server1.lab.example.com] => (item={u'name': u'chrony'})
ok: [server2.lab.example.com] => (item={u'name': u'chrony'})
ok: [ansible.lab.example.com] => (item={u'name': u'chrony'})
ok: [server3.lab.example.com] => (item={u'name': u'chrony'})
ok: [server1.lab.example.com] => (item={u'name': u'bash-completion'})
ok: [ansible.lab.example.com] => (item={u'name': u'bash-completion'})
ok: [server2.lab.example.com] => (item={u'name': u'bash-completion'})
ok: [server3.lab.example.com] => (item={u'name': u'bash-completion'})
ok: [server1.lab.example.com] => (item={u'name': u'yum-utils'})
ok: [server2.lab.example.com] => (item={u'name': u'yum-utils'})
ok: [ansible.lab.example.com] => (item={u'name': u'yum-utils'})
ok: [server3.lab.example.com] => (item={u'name': u'yum-utils'})
ok: [server1.lab.example.com] => (item={u'name': u'bind-utils'})
ok: [server2.lab.example.com] => (item={u'name': u'bind-utils'})
ok: [ansible.lab.example.com] => (item={u'name': u'bind-utils'})
ok: [server3.lab.example.com] => (item={u'name': u'bind-utils'})
ok: [server2.lab.example.com] => (item={u'name': u'net-tools'})
ok: [server1.lab.example.com] => (item={u'name': u'net-tools'})
ok: [ansible.lab.example.com] => (item={u'name': u'net-tools'})
ok: [server3.lab.example.com] => (item={u'name': u'net-tools'})
ok: [server1.lab.example.com] => (item={u'name': u'ntp'})
ok: [server2.lab.example.com] => (item={u'name': u'ntp'})
ok: [ansible.lab.example.com] => (item={u'name': u'ntp'})
ok: [ansible.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server3.lab.example.com] => (item={u'name': u'ntp'})
ok: [server1.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server2.lab.example.com] => (item={u'name': u'firewalld'})
ok: [ansible.lab.example.com] => (item={u'name': u'wget'})
ok: [server3.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server1.lab.example.com] => (item={u'name': u'wget'})
ok: [server2.lab.example.com] => (item={u'name': u'wget'})
ok: [ansible.lab.example.com] => (item={u'name': u'curl'})
ok: [server1.lab.example.com] => (item={u'name': u'curl'})
ok: [server3.lab.example.com] => (item={u'name': u'wget'})
ok: [ansible.lab.example.com] => (item={u'name': u'unzip'})
ok: [server2.lab.example.com] => (item={u'name': u'curl'})
ok: [server1.lab.example.com] => (item={u'name': u'unzip'})
ok: [server3.lab.example.com] => (item={u'name': u'curl'})
ok: [server2.lab.example.com] => (item={u'name': u'unzip'})
ok: [server3.lab.example.com] => (item={u'name': u'unzip'})

TASK [stop the services] *******************************************************************************************
ok: [ansible.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server2.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server3.lab.example.com] => (item={u'name': u'firewalld'})
ok: [server1.lab.example.com] => (item={u'name': u'firewalld'})

TASK [start and enable services] ***********************************************************************************
changed: [ansible.lab.example.com] => (item={u'name': u'chronyd'})
changed: [ansible.lab.example.com] => (item={u'name': u'ntpd'})
changed: [server2.lab.example.com] => (item={u'name': u'chronyd'})
changed: [server3.lab.example.com] => (item={u'name': u'chronyd'})
changed: [server1.lab.example.com] => (item={u'name': u'chronyd'})
changed: [server1.lab.example.com] => (item={u'name': u'ntpd'})
changed: [server3.lab.example.com] => (item={u'name': u'ntpd'})
changed: [server2.lab.example.com] => (item={u'name': u'ntpd'})

TASK [copy configuration files from the URLs] **********************************************************************
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/hosts', u'dest': u'/etc/hosts', u'name': u'hosts'})
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/nsswitch.conf', u'dest': u'/etc/nsswitch.conf', u'name': u'nsswitch.conf'})
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/profile', u'dest': u'/etc/profile', u'name': u'profile'})
ok: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/hosts', u'dest': u'/etc/hosts', u'name': u'hosts'})
ok: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/hosts', u'dest': u'/etc/hosts', u'name': u'hosts'})
ok: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/hosts', u'dest': u'/etc/hosts', u'name': u'hosts'})
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/resolv.conf', u'dest': u'/etc/resolv.conf', u'name': u'resolv.conf'})
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/selinuxconfig', u'dest': u'/etc/selinux/config', u'name': u'selinuxconfig'})
ok: [ansible.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/yum.conf', u'dest': u'/etc/yum.conf', u'name': u'yum.conf'})
ok: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/nsswitch.conf', u'dest': u'/etc/nsswitch.conf', u'name': u'nsswitch.conf'})
ok: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/nsswitch.conf', u'dest': u'/etc/nsswitch.conf', u'name': u'nsswitch.conf'})
ok: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/nsswitch.conf', u'dest': u'/etc/nsswitch.conf', u'name': u'nsswitch.conf'})
changed: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/profile', u'dest': u'/etc/profile', u'name': u'profile'})
changed: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/profile', u'dest': u'/etc/profile', u'name': u'profile'})
changed: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/profile', u'dest': u'/etc/profile', u'name': u'profile'})
ok: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/resolv.conf', u'dest': u'/etc/resolv.conf', u'name': u'resolv.conf'})
ok: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/resolv.conf', u'dest': u'/etc/resolv.conf', u'name': u'resolv.conf'})
ok: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/resolv.conf', u'dest': u'/etc/resolv.conf', u'name': u'resolv.conf'})
ok: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/selinuxconfig', u'dest': u'/etc/selinux/config', u'name': u'selinuxconfig'})
ok: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/selinuxconfig', u'dest': u'/etc/selinux/config', u'name': u'selinuxconfig'})
ok: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/selinuxconfig', u'dest': u'/etc/selinux/config', u'name': u'selinuxconfig'})
ok: [server1.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/yum.conf', u'dest': u'/etc/yum.conf', u'name': u'yum.conf'})
ok: [server2.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/yum.conf', u'dest': u'/etc/yum.conf', u'name': u'yum.conf'})
ok: [server3.lab.example.com] => (item={u'url': u'http://ansible.lab.example.com/config/yum.conf', u'dest': u'/etc/yum.conf', u'name': u'yum.conf'})

PLAY RECAP *********************************************************************************************************
ansible.lab.example.com    : ok=5    changed=1    unreachable=0    failed=0
server1.lab.example.com    : ok=5    changed=2    unreachable=0    failed=0
server2.lab.example.com    : ok=5    changed=2    unreachable=0    failed=0
server3.lab.example.com    : ok=5    changed=2    unreachable=0    failed=0