install_rpm_or_deb.playbook.yaml 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ---
  2. - name: "Install an rpm or deb file using yum/dnf/apt"
  3. hosts: all
  4. gather_facts: True
  5. become: true
  6. vars:
  7. - install_file_path: "include/"
  8. - rpm_filename: "SentinelAgent_linux_v22_4_2_4.rpm"
  9. - deb_filename: "SentinelAgent_linux_v22_4_2_4.deb"
  10. - script_file: "include/activation_script.sh"
  11. - new_host_fqdn: "{{ ansible_fqdn }}"
  12. - site_token: "***CONTENTS REDACTED***"
  13. tasks:
  14. - name: "msg print to stdout: Debug ansible_facts"
  15. debug:
  16. msg:
  17. - ansible_facts.distribution "{{ ansible_facts.distribution }}"
  18. - ansible_facts.distribution_major_version "{{ ansible_facts.distribution_major_version }}"
  19. - ansible_facts.distribution_file_variety "{{ ansible_facts.distribution_file_variety }}"
  20. - name: Populate systemd service_facts
  21. service_facts:
  22. - debug:
  23. msg:
  24. - ansible_facts.services['firewalld.service'] "{{ ansible_facts.services['firewalld.service'] }}"
  25. when: "'firewalld.service' in services"
  26. - debug:
  27. msg:
  28. - ansible_facts.services['iptables.service'] "{{ ansible_facts.services['iptables.service'] }}"
  29. when: "'iptables.service' in services"
  30. - debug:
  31. msg:
  32. - ansible_facts.services['iptables.service'] "{{ ansible_facts.services['iptables.service'] }}"
  33. when: "'ufw.service' in services"
  34. ############################################### Copy source rpm or deb file to be installed #################################################################################
  35. - name: Copy rpm file to host when distribution_file_variety is RedHat
  36. copy:
  37. src: "{{ install_file_path }}{{ rpm_filename }}"
  38. dest: "/home/Ansible/{{ rpm_filename }}"
  39. when: ansible_facts['distribution_file_variety'] == 'RedHat'
  40. - name: Copy deb file to host when distribution_file_variety is Debian
  41. copy:
  42. src: "{{ install_file_path }}{{ deb_filename }}"
  43. dest: "/home/Ansible/{{ deb_filename }}"
  44. when: ansible_facts['distribution_file_variety'] == 'Debian'
  45. ############################################### RH section #################################################################################################
  46. - name: "Perform installation w/ yum and rpm file when distribution_file_variety is RedHat"
  47. yum:
  48. name: /home/Ansible/{{ rpm_filename }}
  49. state: present
  50. disable_gpg_check: true
  51. when:
  52. - ansible_facts['distribution_file_variety'] == 'RedHat'
  53. ############################################### Deb section #################################################################################################
  54. - name: "Install deb file on host when distribution_file_variety is Debian"
  55. apt:
  56. deb: /home/Ansible/{{ deb_filename }}
  57. state: present
  58. when:
  59. - ansible_facts['distribution_file_variety'] == 'Debian'
  60. ############################################### Run activation_script.sh #################################################################################################
  61. - name: "Running activation commands"
  62. command:
  63. cmd: /opt/sentinelone/bin/sentinelctl management token set ***CONTENTS REDACTED***
  64. cmd: /opt/sentinelone/bin/sentinelctl control start