I have a role in ansible working in command line but not through awx.
Here the role :
- name: Enable persistent logging
ansible.builtin.lineinfile:
path: /etc/systemd/journald.conf
regexp: '^#Storage'
line: Storage=persistent
- name: Check directory
ansible.builtin.stat:
path: "{{ journal_dir }}"
register: journaldir
- block:
- name: Create directory
ansible.builtin.file:
path: "{{ journal_dir }}"
state: directory
mode: '0755'
- name: Enable systemd-tmpfiles folder
ansible.builtin.command: /bin/systemd-tmpfiles --create --prefix {{ journal_dir }}
check_mode: no
notify:
- restart systemd-journald
when: journaldir.stat.exists == false and ansible_distribution_major_version >= '7'
Here the notify code :
- name: restart systemd-journald
ansible.builtin.service:
name: systemd-journald
state: restarted
{{ journal_dir }} is /var/log/journal
I have no issue when I run the playbook on my terminal, but when I run it with awx, I still have this error :
TASK [journalctl : Enable systemd-tmpfiles folder] *****************************
fatal: [server]: FAILED! => {"changed": false, "msg": "no command given", "rc": 256}
I have done test also with shell module, it's the same behaviour.
And I don't understand why.
thank you for your help.
I foud the issue, it seems I'm using an old version of ansible, so I had to remove the fqcn for the command module.
It works like this :
- name: Enable systemd-tmpfiles folder
command: /bin/systemd-tmpfiles --create --prefix {{ journal_dir }}
notify:
- restart systemd-journald
my ansible version through command line is 2.9.27,ansible version of awx is 2.9.14.
[solution has been found here] : Ansible cant run any command or shell