FAQ
Helo all,


  I wonder if I can get some help with referencing facts in template.

I ma not able to reference:


  every time I run my play, the file on the host shows:


carp0_ip=””


and the same line in my template:


  carp0_ip=”{{ ansible_carp0[“ipv4”][“address”] }}”


this is the snippet from running: ansible server -m setup


  "ansible_carp0": {
"device": "carp0",
"flags": [
"UP",
"BROADCAST",
"RUNNING",
"SI
"ipv4": [
{
"address": "10.0.0.33",
"broadcast": "10.0.0.255",
"netmask": "255.255.255.0",
"network": "10.0.0.0"
}
],
"ipv6": [
{
"address": "fe80::200:5eff:fe00:101%carp0",
"prefix": "64",
"scope": "0x4"
}
],
"macaddress": "00:00:5e:00:01:04",
"mtu": "1500",
"status": "master",
"type": "unknown"
},


  host where ansible is installed: CentOS 6.5

ansible version: 1.6.6

host I'm pulling facts from: OpenBSD 5.5



Thank you


  Greg

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d4820ae0-eae3-4ad6-aef8-b1570a27d11f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael DeHaan at Jul 23, 2014 at 10:12 pm
    Hmm, can we see a full playbook so we can understand a bit more in context?



    On Wed, Jul 23, 2014 at 5:34 PM, Greg M wrote:

    Helo all,


    I wonder if I can get some help with referencing facts in template.

    I ma not able to reference:


    every time I run my play, the file on the host shows:


    carp0_ip=””


    and the same line in my template:


    carp0_ip=”{{ ansible_carp0[“ipv4”][“address”] }}”


    this is the snippet from running: ansible server -m setup


    "ansible_carp0": {
    "device": "carp0",
    "flags": [
    "UP",
    "BROADCAST",
    "RUNNING",
    "SI
    "ipv4": [
    {
    "address": "10.0.0.33",
    "broadcast": "10.0.0.255",
    "netmask": "255.255.255.0",
    "network": "10.0.0.0"
    }
    ],
    "ipv6": [
    {
    "address": "fe80::200:5eff:fe00:101%carp0",
    "prefix": "64",
    "scope": "0x4"
    }
    ],
    "macaddress": "00:00:5e:00:01:04",
    "mtu": "1500",
    "status": "master",
    "type": "unknown"
    },


    host where ansible is installed: CentOS 6.5

    ansible version: 1.6.6

    host I'm pulling facts from: OpenBSD 5.5



    Thank you


    Greg

    --
    You received this message because you are subscribed to the Google Groups
    "Ansible Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to ansible-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/ansible-project/d4820ae0-eae3-4ad6-aef8-b1570a27d11f%40googlegroups.com
    <https://groups.google.com/d/msgid/ansible-project/d4820ae0-eae3-4ad6-aef8-b1570a27d11f%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "Ansible Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgw08O%2Bc3enOwoTxm_%3D0-rWGnWqSmteOvV5Ucnt9aRtdXA%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Greg M at Jul 24, 2014 at 1:24 pm
    template/relayd.yml.j2:


    # {{ ansible_managed }}
    #

    #
    # Macros
    #
    carp0_ip="{{ ansible_carp0["ipv4"]["address"] }}"
    webhost="{{ web_server }}"

    #
    # Global Options
    #

    interval 10
    log updates
    prefork 5
    timeout 3000

    ...
    # more in the relayd.conf.j2 file, is removed

    the web_server comes from variable file, but the carp0_ip is pulled from
    facts when the play is run
    as user ansible, using sudo


    and the play file: task/main.yml:


    ---
    # file: roles/proxy_server/tasks/main.yml


    # carp0 interface
    - name: carp0 interface file
       template: src=hostname.carp0.j2 dest=/etc/hostname.carp0 owner=root
    group=wheel mode=0640

    - name: install relayd.conf
       template: src=relayd.conf.j2 dest=/etc/relayd.conf owner=root group=wheel
    mode=0644
       notify:
       - restart relayd

    - name: start relayd
       service: name=relayd state=started

    # EOF

       Also one more time the snipet of the command: ansible proxy_server -m
    setup (the original file was not complete(damaged))


            "ansible_architecture": "amd64",
             "ansible_carp0": {
                 "device": "carp0",
                 "flags": [
                     "UP",
                     "BROADCAST",
                     "RUNNING",
                     "SIMPLEX",
                     "MULTICAST"
                 ],
                 "ipv4": [
                     {
                         "address": "10.0.0.33",
                         "broadcast": "10.0.0.255",
                         "netmask": "255.255.255.0",
                         "network": "10.0.0.0"
                     }
                 ],
                 "ipv6": [
                     {
                         "address": "fe80::200:5eff:fe00:101%carp0",
                         "prefix": "64",
                         "scope": "0x4"
                     }
                 ],
                 "macaddress": "00:00:5e:00:01:01",
                 "mtu": "1500",
                 "status": "master",
                 "type": "unknown"
             },
             "ansible_date_time":

    --
    You received this message because you are subscribed to the Google Groups "Ansible Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/fdfff820-a3e0-4290-afea-7038ae530976%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Greg M at Jul 28, 2014 at 9:26 pm

    On Wednesday, July 23, 2014 5:12:52 PM UTC-5, Michael DeHaan wrote:
    Hmm, can we see a full playbook so we can understand a bit more in context?




    On Wed, Jul 23, 2014 at 5:34 PM, Greg M <mrgrz...@gmail.com <javascript:>>
    wrote:
    Helo all,


    I wonder if I can get some help with referencing facts in template.

    I ma not able to reference:


    every time I run my play, the file on the host shows:


    carp0_ip=””


    and the same line in my template:


    carp0_ip=”{{ ansible_carp0[“ipv4”][“address”] }}”


    this is the snippet from running: ansible server -m setup


    "ansible_carp0": {
    "device": "carp0",
    "flags": [
    "UP",
    "BROADCAST",
    "RUNNING",
    "SI
    "ipv4": [
    {
    "address": "10.0.0.33",
    "broadcast": "10.0.0.255",
    "netmask": "255.255.255.0",
    "network": "10.0.0.0"
    }
    ],
    "ipv6": [
    {
    "address": "fe80::200:5eff:fe00:101%carp0",
    "prefix": "64",
    "scope": "0x4"
    }
    ],
    "macaddress": "00:00:5e:00:01:04",
    "mtu": "1500",
    "status": "master",
    "type": "unknown"
    },


    host where ansible is installed: CentOS 6.5

    ansible version: 1.6.6

    host I'm pulling facts from: OpenBSD 5.5



    Thank you


    Greg

    --
    You received this message because you are subscribed to the Google Groups
    "Ansible Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to ansible-proje...@googlegroups.com <javascript:>.
    To post to this group, send email to ansible...@googlegroups.com
    <javascript:>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/ansible-project/d4820ae0-eae3-4ad6-aef8-b1570a27d11f%40googlegroups.com
    <https://groups.google.com/d/msgid/ansible-project/d4820ae0-eae3-4ad6-aef8-b1570a27d11f%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
      Thank you for your replay.
    after farther testing i was able to reproduce the error
    the error only shows on BSD system (Open, Free)

    sample host file:

    # ansible host file
    #
    # testing

    openbsd_host ansible_ssh_host=owaa
    linux_host ansible_ssh_host=metis
    freebsd_host ansible_ssh_host=hosta

    [linux_servers]
    linux_host

    [openbsd_servers]
    openbsd_host

    [freebsd_servers]
    freebsd_host

    [freebsd_servers:vars]
    ansible_python_interpreter=/usr/local/bin/python2

    [openbsd_servers:vars]
    ansible_python_interpreter=/usr/local/bin/python

    [linux_servers:vars]
    ansible_python_interpreter=/usr/bin/python



    sample play file:

    ---
    # test.yml

    - hosts: linux_host
       remote_user: gregm

       tasks:
       # name: address (frrebsd and openbsd replace with em0 ans nic)
       - debug: msg={{ ansible_eth0.ipv4.address }}



    when the play is run against linux box:


    PLAY [linux_host]
    *************************************************************

    GATHERING FACTS
    ***************************************************************
    ok: [linux_host]

    TASK: [debug msg={{ansible_eth0.ipv4.address}}]
    *******************************
    ok: [linux_host] => {
    "msg": "192.168.0.7"
    }

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




    but when run against any of the BSD system:


    PLAY [openbsd_host]
    ***********************************************************

    GATHERING FACTS
    ***************************************************************
    ok: [openbsd_host]

    TASK: [debug msg={{ansible_em0.ipv4.address}}]
    ********************************
    ok: [openbsd_host] => {
    "msg": "{{ansible_em0.ipv4.address}}"
    }

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


    i hope it will help

    Thank you
    Greg

    --
    You received this message because you are subscribed to the Google Groups "Ansible Project" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/aca2864c-d397-4e34-8fbc-c73f5b9e18ee%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupansible-project @
postedJul 23, '14 at 9:52p
activeJul 28, '14 at 9:26p
posts4
users2

2 users in discussion

Greg M: 3 posts Michael DeHaan: 1 post

People

Translate

site design / logo © 2022 Grokbase