install_rpm_or_deb.playbook.yaml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: "filename_v22_4_2_4.rpm"
  9. - deb_filename: "filename_v22_4_2_4.deb"
  10. - new_host_fqdn: "{{ ansible_fqdn }}"
  11. #### s1-speficic:
  12. - site_token: "***CONTENTS REDACTED***"
  13. tasks:
  14. - name: "msg print to stdout: Debug ansible_facts"
  15. debug:
  16. msg:
  17. # - "{{ ansible_facts.service_mgr }}"
  18. - ansible_facts.distribution "{{ ansible_facts.distribution }}"
  19. - ansible_facts.distribution_major_version "{{ ansible_facts.distribution_major_version }}"
  20. - ansible_facts.distribution_file_variety "{{ ansible_facts.distribution_file_variety }}"
  21. - name: Populate systemd service_facts
  22. service_facts:
  23. - debug:
  24. msg:
  25. - ansible_facts.services['firewalld.service'] "{{ ansible_facts.services['firewalld.service'] }}"
  26. when: "'firewalld.service' in services"
  27. - debug:
  28. msg:
  29. - ansible_facts.services['iptables.service'] "{{ ansible_facts.services['iptables.service'] }}"
  30. when: "'iptables.service' in services"
  31. - debug:
  32. msg:
  33. - ansible_facts.services['iptables.service'] "{{ ansible_facts.services['iptables.service'] }}"
  34. when: "'ufw.service' in services"
  35. ############################################### Copy source rpm or deb file to be installed #################################################################################
  36. - name: Copy deb file to host when distribution_file_variety is RedHat
  37. copy:
  38. src: "{{ install_file_path }}{{ rpm_filename }}"
  39. dest: /home/Ansible/{{{ rpm_filename }}
  40. when: ansible_facts['distribution_file_variety'] == 'RedHat'
  41. - name: Copy deb file to host when distribution_file_variety is Debian
  42. copy:
  43. src: "{{ install_file_path }}{{ deb_filename }}"
  44. dest: /home/Ansible/{{ deb_filename }}
  45. when: ansible_facts['distribution_file_variety'] == 'Debian'
  46. ############################################### RH section #################################################################################################
  47. - name: "Perform installation w/ yum and rpm file when distribution_file_variety is RedHat"
  48. yum:
  49. name: /home/Ansible/{{ rpm_filename }}
  50. state: present
  51. disable_gpg_check: true
  52. when:
  53. - ansible_facts['distribution_file_variety'] == 'RedHat'
  54. ############################################### Deb section #################################################################################################
  55. - name: "Install deb file on host when distribution_file_variety is Debian"
  56. apt:
  57. deb: /home/Ansible/{{ deb_filename }}
  58. state: present
  59. when:
  60. - ansible_facts['distribution_file_variety'] == 'Debian'
  61. ############################################### Run activation_script.sh #################################################################################################
  62. - name: "Running activation_script.sh"
  63. shell: include/activation_script.sh