system_container.yml 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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:
  30. - task_result is failed
  31. - ('could not' not in task_result.msg|lower)
  32. when: "'etcd' not in etcd_result.stdout"
  33. - name: Disable etcd_container
  34. systemd:
  35. name: etcd_container
  36. state: stopped
  37. enabled: no
  38. daemon_reload: yes
  39. register: task_result
  40. failed_when:
  41. - task_result is failed
  42. - ('could not' not in task_result.msg|lower)
  43. - name: Remove etcd_container.service
  44. file:
  45. path: /etc/systemd/system/etcd_container.service
  46. state: absent
  47. - name: Systemd reload configuration
  48. systemd: name=etcd_container daemon_reload=yes
  49. - name: Install or Update Etcd system container package
  50. oc_atomic_container:
  51. name: etcd
  52. image: "{{ etcd_image }}"
  53. state: latest
  54. values:
  55. - ETCD_DATA_DIR=/var/lib/etcd
  56. - ETCD_LISTEN_PEER_URLS={{ etcd_listen_peer_urls }}
  57. - ETCD_NAME={{ etcd_hostname }}
  58. - ETCD_INITIAL_CLUSTER={{ etcd_initial_cluster }}
  59. - ETCD_LISTEN_CLIENT_URLS={{ etcd_listen_client_urls }}
  60. - ETCD_INITIAL_ADVERTISE_PEER_URLS={{ etcd_initial_advertise_peer_urls }}
  61. - ETCD_INITIAL_CLUSTER_STATE={{ etcd_initial_cluster_state }}
  62. - ETCD_INITIAL_CLUSTER_TOKEN={{ etcd_initial_cluster_token }}
  63. - ETCD_ADVERTISE_CLIENT_URLS={{ etcd_advertise_client_urls }}
  64. - ETCD_CA_FILE={{ etcd_ca_file }}
  65. - ETCD_CERT_FILE={{ etcd_cert_file }}
  66. - ETCD_KEY_FILE={{ etcd_key_file }}
  67. - ETCD_PEER_CA_FILE={{ etcd_peer_ca_file }}
  68. - ETCD_PEER_CERT_FILE={{ etcd_peer_cert_file }}
  69. - ETCD_PEER_KEY_FILE={{ etcd_peer_key_file }}
  70. - ETCD_TRUSTED_CA_FILE={{ etcd_ca_file }}
  71. - ETCD_PEER_TRUSTED_CA_FILE={{ etcd_peer_ca_file }}
  72. - '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"]}'
  73. - name: Ensure etcd datadir ownership for the system container
  74. file:
  75. path: "{{ etcd_data_dir }}"
  76. state: directory
  77. mode: 0700
  78. owner: root
  79. group: root
  80. recurse: True