Closed LuigiDC closed 7 years ago
If you are referring to roles/yavdr-xorg/read_xrandr.py - this script is not used by ansible (it was an early draft I forgot to remove from the git repository).
https://github.com/yavdr/yavdr-ansible/blob/master/roles/yavdr-xorg/tasks/detect-xorg.yml#L43 calls https://github.com/yavdr/yavdr-ansible/blob/master/library/xrandr_facts.py
I saw it already. Just used it to debug my output and to make the first steps with yavdr-ansible + python.
I'm already analyzing and testing the skripts which are called by detect-xorg.yml
.
Netherless, detect-xorg.yml
seems to call xrandr_facts.py
which itselfs calls xrandr --verbose
in an subprocess for a more detailed output. I would guess that it also requires the DISPLAY=:0
environment.
display is set to :0
by default: https://github.com/yavdr/yavdr-ansible/blob/master/library/xrandr_facts.py#L60 and used as an argument (resulting in -d :0
) for the xrandr call: https://github.com/yavdr/yavdr-ansible/blob/master/library/xrandr_facts.py#L263
Correctly. I removed the envvar and tried to localy call the python script in the bash. I'm getting the some errors:
xrandr: unrecognized option '-d :0 --verbose'
Try 'xrandr --help' for more information.
Traceback (most recent call last):
File "/home/luigi/yavdr-ansible/library/xrandr_facts.py", line 263, in <module>
d = subprocess.check_output(['xrandr', '-d :0 --verbose'], universal_newlines=True).splitlines()
File "/usr/lib/python2.7/subprocess.py", line 574, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command '['xrandr', '-d :0 --verbose']' returned non-zero exit status 1
xrandr -d :0 --verbose
Screen 0: minimum 8 x 8, current 1280 x 1024, maximum 16384 x 16384
VGA-0 disconnected (normal left inverted right x axis y axis)
Identifier: 0x27e
Timestamp: 17047
Subpixel: unknown
Clones:
CRTCs: 0 1 2 3
Transform: 1.000000 0.000000 0.000000
0.000000 1.000000 0.000000
0.000000 0.000000 1.000000
filter:
CscMatrix: 65536 0 0 0 0 65536 0 0 0 0 65536 0
.....
I think that should be ['xrandr', '-d :0', '--verbose']
.
Still the same problem. I tried today the command on an virtual machine and it worked as expected. I changed the command to
d = subprocess.check_output(['xrandr -d :0 --verbose'], shell=True, universal_newlines=True).splitlines()
and the command was executed without errors.
Edit 1: The rest of the script worked as expected except the following points.
Edit 2: The correct line should be (of course):
d = subprocess.check_output(['xrandr', '-d', ':0', '--verbose'], universal_newlines=True).splitlines()
and it worked.
As i can see problem lies in the line
module = AnsibleModule(argument_spec=ARG_SPECS, supports_check_mode=False,)
The module hangs up during the initial. If i break the execution the following error occurs in the debugger
module = AnsibleModule(argument_spec=ARG_SPECS, supports_check_mode=False,)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/dist-packages/ansible/module_utils/basic.py", line 701, in __init__
self._load_params()
File "/usr/lib/python2.7/dist-packages/ansible/module_utils/basic.py", line 1768, in _load_params
self.params = _load_params()
File "/usr/lib/python2.7/dist-packages/ansible/module_utils/basic.py", line 603, in _load_params
buffer = sys.stdin.read()
If the module isnt initialized the xrandr
call gets no display port.
I can replace all vars which depends on module.* by the dictionary value directly like
ARG_SPECS['display']['default']
and it works.
Have a look at https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html - you need a special environment to run Ansible modules, the python Interpreter on it's own is not enough.
Right. Now runs like a charm.
The command
xrandr -q
executed by the xorg detection creates the error 'Cant open display'. Therefore the video modes are not correctly detected for the generation of the xorg.conf.Actual solution: My workoaround was to add a envvar
export DISPLAY=:0
to the ./bashrc to get the output details fromxrandr -q
.Netherless the xorg.conf doesnt contain the new entries automatically.