1- name: install the test daemon script
2  copy:
3    src: ansible_test_service.py
4    dest: /usr/sbin/ansible_test_service
5    mode: '755'
6
7- name: rewrite shebang in the test daemon script
8  lineinfile:
9    path: /usr/sbin/ansible_test_service
10    line: "#!{{ ansible_python_interpreter | realpath }}"
11    insertbefore: BOF
12    firstmatch: yes
13
14- name: install the systemd unit file
15  copy:
16    src: ansible.systemd
17    dest: /etc/systemd/system/ansible_test.service
18    mode: '0644'
19  register: install_systemd_result
20
21- name: assert that the systemd unit file was installed
22  assert:
23    that:
24    - "install_systemd_result.dest == '/etc/systemd/system/ansible_test.service'"
25    - "install_systemd_result.state == 'file'"
26    - "install_systemd_result.mode == '0644'"
27