Hi Chaz,

On 1/14/19 11:02 AM, Chaz_E wrote:
I like the idea of this suggestion.
Is local-facts-facts-d <https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html#local-facts-facts-d> usable as Non-Root?

They come up as part of the dictionary returned by the setup module as*ansible_local,* so yes.

Can facts be loaded from the user's $HOME/.ansible/ , like $HOME/.ansible/facts.d or something like that?
I see for windows there is fact_path does that work for Linux?

Reading https://docs.ansible.com/ansible/2.4/intro_configuration.html#fact-path it has precisely that use case (a user's HOME). I don't see that it should not work for Linux. You should try it on a host and see.

Now, back to what you're trying to do. Your variable file is almost an INI file, it just needs a section.

I was curious, so I tried something like what you're trying to do:

[root@gladys facts.d]# pwd
*/etc/ansible/facts.d*

[root@gladys facts.d]# ls -l
total 4***-rwxr-xr-x. 1 root root 106 Jan 14 18:47 factfile.fact*

[root@gladys facts.d]# cat factfile.fact
*#!/bin/bash****# An ini file must have a section****echo '[general]'****cat 
/home/management/thishasvariables.txt*

[root@gladys facts.d]# ls -l /home/management/thishasvariables.txt***-rw-r--r--. 1 management management 11 Jan 14 18:48 /home/management/thishasvariables.txt*

[root@gladys facts.d]# cat /home/management/thishasvariables.txt
*spam=eggs*


my_user@mybox:~$ ansible -u management -i 'gladys, ' all -m setup  -a 
"filter=ansible_local"
*gladys | SUCCESS => {****"ansible_facts": {****"ansible_local": {****"factfile": {****"general": 
{****"spam": "eggs"****}****}****}****}, ****"changed": false****}*



This works. Whether it is secure or not, that's a different matter, it does 
take a user-supplied file and present it as facts for the host.
Cheers,

Hugo









--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b0d9fb18-f3a0-8460-b792-3610857222f1%40redhat.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to