system_container.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. ---
  2. - name: Pull etcd system container
  3. command: atomic pull --storage=ostree {{ etcd_image }}
  4. register: pull_result
  5. changed_when: "'Pulling layer' in pull_result.stdout"
  6. - name: Set initial Etcd cluster
  7. set_fact:
  8. etcd_initial_cluster: >-
  9. {% for host in etcd_peers | default([]) -%}
  10. {% if loop.last -%}
  11. {{ hostvars[host].etcd_hostname }}={{ etcd_peer_url_scheme }}://{{ hostvars[host].etcd_ip }}:{{ etcd_peer_port }}
  12. {%- else -%}
  13. {{ hostvars[host].etcd_hostname }}={{ etcd_peer_url_scheme }}://{{ hostvars[host].etcd_ip }}:{{ etcd_peer_port }},
  14. {%- endif -%}
  15. {% endfor -%}
  16. when: etcd_initial_cluster is undefined
  17. - name: Check etcd system container package
  18. command: >
  19. atomic containers list --no-trunc -a -f container=etcd -f backend=ostree
  20. register: etcd_result
  21. - name: Unmask etcd service
  22. systemd:
  23. name: etcd
  24. state: stopped
  25. enabled: no
  26. masked: no
  27. daemon_reload: yes
  28. register: task_result
  29. failed_when: task_result|failed and 'could not' not in task_result.msg|lower
  30. when: "'etcd' not in etcd_result.stdout"
  31. - name: Disable etcd_container
  32. systemd:
  33. name: etcd_container
  34. state: stopped
  35. enabled: no
  36. daemon_reload: yes
  37. register: task_result
  38. failed_when: task_result|failed and 'could not' not in task_result.msg|lower
  39. - name: Remove etcd_container.service
  40. file:
  41. path: /etc/systemd/system/etcd_container.service
  42. state: absent
  43. - name: Systemd reload configuration
  44. systemd: name=etcd_container daemon_reload=yes
  45. - name: Install or Update Etcd system container package
  46. oc_atomic_container:
  47. name: etcd
  48. image: "{{ etcd_image }}"
  49. state: latest
  50. values:
  51. - ETCD_DATA_DIR=/var/lib/etcd
  52. - ETCD_LISTEN_PEER_URLS={{ etcd_listen_peer_urls }}
  53. - ETCD_NAME={{ etcd_hostname }}
  54. - ETCD_INITIAL_CLUSTER={{ etcd_initial_cluster }}
  55. - ETCD_LISTEN_CLIENT_URLS={{ etcd_listen_client_urls }}
  56. - ETCD_INITIAL_ADVERTISE_PEER_URLS={{ etcd_initial_advertise_peer_urls }}
  57. - ETCD_INITIAL_CLUSTER_STATE={{ etcd_initial_cluster_state }}
  58. - ETCD_INITIAL_CLUSTER_TOKEN={{ etcd_initial_cluster_token }}
  59. - ETCD_ADVERTISE_CLIENT_URLS={{ etcd_advertise_client_urls }}
  60. - ETCD_CA_FILE={{ etcd_ca_file }}
  61. - ETCD_CERT_FILE={{ etcd_cert_file }}
  62. - ETCD_KEY_FILE={{ etcd_key_file }}
  63. - ETCD_PEER_CA_FILE={{ etcd_peer_ca_file }}
  64. - ETCD_PEER_CERT_FILE={{ etcd_peer_cert_file }}
  65. - ETCD_PEER_KEY_FILE={{ etcd_peer_key_file }}
  66. - ETCD_TRUSTED_CA_FILE={{ etcd_ca_file }}
  67. - ETCD_PEER_TRUSTED_CA_FILE={{ etcd_peer_ca_file }}
  68. - 'ADDTL_MOUNTS=,{"type":"bind","source":"/etc/","destination":"/etc/","options":["rbind","rw","rslave"]},{"type":"bind","source":"/var/lib/etcd","destination":"/var/lib/etcd/","options":["rbind","rw","rslave"]}'
  69. - name: Ensure etcd datadir ownership for the system container
  70. file:
  71. path: "{{ etcd_data_dir }}"
  72. state: directory
  73. mode: 0700
  74. owner: root
  75. group: root
  76. recurse: True