10-quay-tmp-fixes.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. ---
  2. # These are the temporary tasks needed on workstation before classroom build is finished.
  3. - name: Fixes required on utility VM.
  4. hosts: utility.lab.example.com
  5. become: yes
  6. gather_facts: no
  7. tasks:
  8. # Fixing the DNS first.
  9. - name: add ocp4.example.com hosts to /etc/hosts
  10. become: yes
  11. ansible.builtin.lineinfile:
  12. path: /etc/hosts
  13. mode: 0644
  14. regex: "{{ item.hostname }}"
  15. line: "{{ item.addr }} {{ item.hostname }}"
  16. state: present
  17. loop:
  18. - addr: 192.168.50.40
  19. hostname: idm.ocp4.example.com
  20. - addr: 192.168.50.50
  21. hostname: registry.ocp4.example.com
  22. - addr: 192.168.50.10
  23. hostname: master01.ocp4.example.com
  24. - addr: 192.168.50.11
  25. hostname: master02.ocp4.example.com
  26. - addr: 192.168.50.12
  27. hostname: master03.ocp4.example.com
  28. - addr: 192.168.50.13
  29. hostname: worker01.ocp4.example.com
  30. - addr: 192.168.50.14
  31. hostname: worker02.ocp4.example.com
  32. - name: Ensure dnsmasq is installed.
  33. ansible.builtin.yum:
  34. name:
  35. - dnsmasq
  36. - dnsmasq-utils
  37. state: present
  38. - name: Ensure dnsmasq is listening on all interfaces
  39. ansible.builtin.lineinfile:
  40. path: /etc/dnsmasq.conf
  41. mode: 0644
  42. regex: "^interface=(.*)$"
  43. line: '#interface=\g<1>'
  44. backrefs: yes
  45. - name: Ensure dnsmasq is enabled and running.
  46. ansible.builtin.systemd_service:
  47. name: dnsmasq
  48. enabled: yes
  49. state: started
  50. - name: Ensure DNS is open in the firewall.
  51. ansible.posix.firewalld:
  52. immediate: yes
  53. permanent: yes
  54. zone: "{{ item }}"
  55. service: dns
  56. state: enabled
  57. loop:
  58. - external
  59. - public
  60. - name: Ensure utility allows forwarding traffic from external to public/trusted zones.
  61. ansible.builtin.copy:
  62. dest: /etc/firewalld/policies/fwd-stud-to-ocp.xml
  63. mode: 0644
  64. owner: root
  65. group: root
  66. content: |
  67. <?xml version="1.0" encoding="utf-8"?>
  68. <policy target="ACCEPT">
  69. <ingress-zone name="external"/>
  70. <egress-zone name="public"/>
  71. <egress-zone name="trusted"/>
  72. </policy>
  73. notify:
  74. - reload utility firewalld
  75. handlers:
  76. - name: reload utility firewalld
  77. ansible.builtin.service:
  78. name: firewalld
  79. state: reloaded
  80. - name: Fix registry VM configuration.
  81. hosts: registry.ocp4.example.com
  82. become: yes
  83. gather_facts: no
  84. tasks:
  85. - name: Ensure eth1 interface is in public zone.
  86. ansible.builtin.firewalld:
  87. zone: public
  88. interface: eth1
  89. immediate: yes
  90. permanent: yes
  91. state: enabled
  92. notify:
  93. - reload registry firewalld
  94. #- name: Ensure registry is using bastion as the DNS
  95. # community.general.nmcli:
  96. # conn_name: "System eth1"
  97. # dns4: 172.25.250.254
  98. # state: present
  99. # notify:
  100. # - bounce eth1
  101. handlers:
  102. - name: reload registry firewalld
  103. ansible.builtin.service:
  104. name: firewalld
  105. state: reloaded
  106. #- name: reload connections
  107. # listen: bounce eth1
  108. # ansible.builtin.command: nmcli con reload
  109. #- name: take eth1 down
  110. # listen: bounce eth1
  111. # ansible.builtin.command: nmcli con down "System eth1"
  112. #- name: bring eth1 up
  113. # listen: bounce eth1
  114. # ansible.builtin.command: nmcli con up "System eth1"
  115. ...