main.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. # This role contains common plays that will run on all nodes
  3. - name: ensure group exists
  4. group:
  5. name: yunion
  6. state: present
  7. - name: ensure user exists
  8. user:
  9. name: yunion
  10. shell: /bin/bash
  11. groups: yunion
  12. - name: make cache for centos x86
  13. shell: |
  14. yum clean all
  15. yum -y --disablerepo='*' --enablerepo='yunion*' makecache
  16. when:
  17. - is_centos_based is defined
  18. - name: make cache for debian like os
  19. shell: "apt-get update"
  20. when:
  21. - is_debian_based is defined
  22. - name: init dirs
  23. shell: "mkdir -p /etc/docker"
  24. - name: config ntpd service
  25. template: src=ntp.conf dest=/etc/ntp.conf
  26. when: ntpd_server is defined
  27. - name: sync with ntpd_server
  28. shell: |
  29. echo "sync with ntpd {{ ntpd_server }}"
  30. systemctl stop ntpd
  31. ntpdate {{ ntpd_server }}; echo $?
  32. echo "[PASS] sync with ntpd {{ ntpd_server }}"
  33. when: ntpd_server is defined
  34. ignore_errors: yes
  35. changed_when: false
  36. failed_when: false
  37. - name: enable services
  38. service:
  39. name: "{{ item }}"
  40. state: started
  41. enabled: yes
  42. with_items:
  43. - "{{ common_services }}"
  44. when:
  45. - common_services is defined
  46. - name: Stop/Disable Depreciated Services If Any
  47. shell: |
  48. for service in yunion-host-image yunion-host-sdnagent firewalld
  49. do
  50. if [ -f /usr/lib/systemd/system/$service.service ]; then
  51. systemctl disable --now $service
  52. fi
  53. done
  54. become: true
  55. args:
  56. executable: /bin/bash
  57. ignore_errors: yes
  58. changed_when: false
  59. failed_when: false