--- - hosts: all become: yes become_method: sudo tasks: - name: Get current chrony.conf ansible.builtin.shell: grep server /etc/chrony.conf | grep -v ^# register: chronyconf - name: Output servers of chrony.conf ansible.builtin.debug: var: chronyconf.stdout - name: Get chronyc sources ansible.builtin.shell: sudo chronyc -n sources|grep ^=== -A3|grep -v ^=== register: chronysources - name: Output chronyc sources ansible.builtin.debug: var: chronysources.stdout