main.yml 960 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. - name: Sort service list
  2. set_fact:
  3. service_list: >-
  4. {{
  5. ((status_services + status_services_extra)|list
  6. | map('length') | list)
  7. | zip(status_services + status_services_extra|list)
  8. | list
  9. | sort(attribute=0, reverse=true)
  10. | map('last')
  11. | list
  12. }}
  13. - debug:
  14. var: service_list
  15. - name: Install statusservices script
  16. template:
  17. src: statusservices.j2
  18. dest: /usr/local/bin/statusservices
  19. owner: root
  20. group: root
  21. mode: '0755'
  22. when:
  23. - service_list|length > 0
  24. - name: Ensure root .bash_profile.local exists
  25. ansible.builtin.file:
  26. path: /root/.bash_profile.local
  27. state: touch
  28. owner: root
  29. group: root
  30. mode: '0640'
  31. changed_when: false
  32. - name: Add statusservices to .bash_profile.local
  33. lineinfile:
  34. path: /root/.bash_profile.local
  35. line: '/usr/local/bin/statusservices'
  36. state: present
  37. when:
  38. - service_list|length > 0