- name: retrieve nonsudo facts
setup:
register: nsfacts
- name: retr. sudo facts
setup:
sudo: yes
--
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.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/bdf5c95e-65ae-4bfc-ab6b-cada3d54c138%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
/etc/ansible/facts.d/node_guid.fact#! /usr/bin/env python
import sys
import json
def get_prop(line):
return line.split("=")[1].strip()
try:
f = open('/etc/zypp/credentials.d/NCCcredentials')
except IOError:
print("{}")
sys.exit(0)
context = {}
keys = ['username']
for line in f:
for key in keys:
if line.startswith(key):
context[key] = get_prop(line)
print json.dumps(context)
sys.exit(0)
/etc/zypp/credentials.d/NCCcredentials' is set readable only for root. Therefore 'node_guid.fact' only returns facts as sudo. Which is the reason why I call the setup module with `sudo:yes`--
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.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/d8c410ce-bbdf-49c6-bce5-ccaaf712405d%40googlegroups.com.