mirror of
https://github.com/iiab/iiab.git
synced 2025-03-09 15:40:17 +00:00
move xsce_env.py.j2 to prep.yml
This commit is contained in:
parent
8b8cf84489
commit
1b476f9a0a
2 changed files with 31 additions and 0 deletions
|
@ -40,6 +40,10 @@
|
||||||
group=root
|
group=root
|
||||||
mode=0644
|
mode=0644
|
||||||
|
|
||||||
|
- name: put a python interface to xsce.env
|
||||||
|
template: src=xsce_env.py
|
||||||
|
dest=/etc/xsce/xsce_env.py
|
||||||
|
|
||||||
- name: create ansible.d facts directory
|
- name: create ansible.d facts directory
|
||||||
file: path=/etc/ansible/facts.d
|
file: path=/etc/ansible/facts.d
|
||||||
owner=root
|
owner=root
|
||||||
|
|
27
roles/1-prep/templates/xsce_env.py.j2
Normal file
27
roles/1-prep/templates/xsce_env.py.j2
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/python
|
||||||
|
# read xsce.env from python
|
||||||
|
|
||||||
|
def get_xsce_env(name):
|
||||||
|
""" read xsce.env file for a value, return "" if does not exist"""
|
||||||
|
try:
|
||||||
|
fd = open("/etc/xsce/xsce.env","r")
|
||||||
|
for line in fd:
|
||||||
|
line = line.lstrip()
|
||||||
|
line = line.rstrip('\n')
|
||||||
|
if len(line) == 0:
|
||||||
|
continue
|
||||||
|
if line[0] == "#":
|
||||||
|
continue
|
||||||
|
if line.find("=") == -1:
|
||||||
|
continue
|
||||||
|
chunks = line.split('=')
|
||||||
|
if chunks[0] == name:
|
||||||
|
return chunks[1]
|
||||||
|
return("")
|
||||||
|
except:
|
||||||
|
return("")
|
||||||
|
finally:
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(get_xsce_env("WWWROOT"))
|
Loading…
Add table
Add a link
Reference in a new issue