system_container.yml 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. ---
  2. - name: Ensure proxies are in the atomic.conf
  3. include_role:
  4. name: openshift_atomic
  5. tasks_from: proxy
  6. - name: Pull etcd system container
  7. command: atomic pull --storage=ostree {{ etcd_image }}
  8. register: pull_result
  9. changed_when: "'Pulling layer' in pull_result.stdout"
  10. - name: Set initial Etcd cluster
  11. set_fact:
  12. etcd_initial_cluster: >-
  13. {% for host in etcd_peers | default([]) -%}
  14. {% if loop.last -%}
  15. {{ hostvars[host].etcd_hostname }}={{ etcd_peer_url_scheme }}://{{ hostvars[host].etcd_ip }}:{{ etcd_peer_port }}
  16. {%- else -%}
  17. {{ hostvars[host].etcd_hostname }}={{ etcd_peer_url_scheme }}://{{ hostvars[host].etcd_ip }}:{{ etcd_peer_port }},
  18. {%- endif -%}
  19. {% endfor -%}
  20. when: etcd_initial_cluster is undefined
  21. - name: Check etcd system container package
  22. command: >
  23. atomic containers list --no-trunc -a -f container=etcd -f backend=ostree
  24. register: etcd_result
  25. - name: Unmask etcd service
  26. systemd:
  27. name: etcd
  28. state: stopped
  29. enabled: no
  30. masked: no
  31. daemon_reload: yes
  32. register: task_result
  33. failed_when: task_result|failed and 'could not' not in task_result.msg|lower
  34. when: "'etcd' not in etcd_result.stdout"
  35. - name: Disable etcd_container
  36. systemd:
  37. name: etcd_container
  38. state: stopped
  39. enabled: no
  40. daemon_reload: yes
  41. register: task_result
  42. failed_when: task_result|failed and '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