I'd like to load facts for a host that are defined in a JSON file on the
control machine. The json file (along with the playbooks) is in a repo that
multiple people can check out, and so I don't want to require that each
user who checks out the repo copies this file to /etc/ansible/facts.d.

Is there another way to load a JSON file that lives on the control machine
and use its contents to populate variables?

I ended up writing a custom facts module to do this, but it seems like
overkill.

Lorin

--
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/3ac701bb-f237-40ec-a524-cc5baab6e3e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Brian Coca at Nov 20, 2014 at 6:32 pm
    you can load it as extra vars with -e @/pathto/jsonfile.json

    On Thu, Nov 20, 2014 at 1:30 PM, Lorin Hochstein
    wrote:
    I'd like to load facts for a host that are defined in a JSON file on the
    control machine. The json file (along with the playbooks) is in a repo that
    multiple people can check out, and so I don't want to require that each user
    who checks out the repo copies this file to /etc/ansible/facts.d.

    Is there another way to load a JSON file that lives on the control machine
    and use its contents to populate variables?

    I ended up writing a custom facts module to do this, but it seems like
    overkill.

    Lorin

    --
    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/3ac701bb-f237-40ec-a524-cc5baab6e3e5%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Brian Coca

    --
    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/CAJ5XC8n2ca_EgoMyJwGJ3OpCk4HEq22Qyp7kGN-crg%2BghdSCHQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Lorin Hochstein at Nov 20, 2014 at 6:44 pm
    Cool. Is there a way to specify this in the playbook itself (other than in
    the shebang)? Something like vars_files that speaks json?

    On Thu, Nov 20, 2014 at 1:32 PM, Brian Coca wrote:

    you can load it as extra vars with -e @/pathto/jsonfile.json

    On Thu, Nov 20, 2014 at 1:30 PM, Lorin Hochstein
    wrote:
    I'd like to load facts for a host that are defined in a JSON file on the
    control machine. The json file (along with the playbooks) is in a repo that
    multiple people can check out, and so I don't want to require that each user
    who checks out the repo copies this file to /etc/ansible/facts.d.

    Is there another way to load a JSON file that lives on the control machine
    and use its contents to populate variables?

    I ended up writing a custom facts module to do this, but it seems like
    overkill.

    Lorin

    --
    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/3ac701bb-f237-40ec-a524-cc5baab6e3e5%40googlegroups.com
    .
    For more options, visit https://groups.google.com/d/optout.


    --
    Brian Coca

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Ansible Project" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/ansible-project/I56gGMFZpJs/unsubscribe.
    To unsubscribe from this group and all its topics, 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/CAJ5XC8n2ca_EgoMyJwGJ3OpCk4HEq22Qyp7kGN-crg%2BghdSCHQ%40mail.gmail.com
    .
    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/CACkJihNK8fRnprn4pCGNm8Rtxjh4Jt2TWLreEOCHbtTSMz1yGQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.
  • Brian Coca at Nov 20, 2014 at 7:05 pm
    considering that json is a subset of yaml, you should be able to load them.

    On Thu, Nov 20, 2014 at 1:44 PM, Lorin Hochstein
    wrote:
    Cool. Is there a way to specify this in the playbook itself (other than in
    the shebang)? Something like vars_files that speaks json?

    On Thu, Nov 20, 2014 at 1:32 PM, Brian Coca wrote:

    you can load it as extra vars with -e @/pathto/jsonfile.json

    On Thu, Nov 20, 2014 at 1:30 PM, Lorin Hochstein
    wrote:
    I'd like to load facts for a host that are defined in a JSON file on the
    control machine. The json file (along with the playbooks) is in a repo
    that
    multiple people can check out, and so I don't want to require that each
    user
    who checks out the repo copies this file to /etc/ansible/facts.d.

    Is there another way to load a JSON file that lives on the control
    machine
    and use its contents to populate variables?

    I ended up writing a custom facts module to do this, but it seems like
    overkill.

    Lorin

    --
    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/3ac701bb-f237-40ec-a524-cc5baab6e3e5%40googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    Brian Coca

    --
    You received this message because you are subscribed to a topic in the
    Google Groups "Ansible Project" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/ansible-project/I56gGMFZpJs/unsubscribe.
    To unsubscribe from this group and all its topics, 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/CAJ5XC8n2ca_EgoMyJwGJ3OpCk4HEq22Qyp7kGN-crg%2BghdSCHQ%40mail.gmail.com.
    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/CACkJihNK8fRnprn4pCGNm8Rtxjh4Jt2TWLreEOCHbtTSMz1yGQ%40mail.gmail.com.

    For more options, visit https://groups.google.com/d/optout.


    --
    Brian Coca

    --
    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/CAJ5XC8kKQVcr-aybSYbWe5FdPm%2Bg6X-Hp7GiRLeToUFvUveUYg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupansible-project @
postedNov 20, '14 at 6:30p
activeNov 20, '14 at 7:05p
posts4
users2

2 users in discussion

Brian Coca: 2 posts Lorin Hochstein: 2 posts

People

Translate

site design / logo © 2022 Grokbase