static.yml 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. ---
  2. # Set some facts to reference from hostvars
  3. - import_tasks: set_facts.yml
  4. - name: Check that etcd image is present
  5. command: 'docker images -q "{{ etcd_image }}"'
  6. register: etcd_image_exists
  7. - name: Pre-pull etcd image
  8. docker_image:
  9. name: "{{ etcd_image }}"
  10. environment:
  11. NO_PROXY: "{{ openshift.common.no_proxy | default('') }}"
  12. when: etcd_image_exists.stdout_lines == []
  13. # 10 minutes to pull the image
  14. async: 600
  15. poll: 0
  16. register: etcd_prepull
  17. - import_tasks: drop_etcdctl.yml
  18. - name: setup firewall
  19. import_tasks: firewall.yml
  20. # TODO: this task may not be needed with Validate permissions
  21. - name: Ensure etcd datadir exists
  22. file:
  23. path: "{{ etcd_data_dir }}"
  24. state: directory
  25. mode: 0700
  26. - name: Validate permissions on the config dir
  27. file:
  28. path: "{{ etcd_conf_dir }}"
  29. state: directory
  30. mode: 0700
  31. - name: Validate permissions on the static pods dir
  32. file:
  33. path: "{{ etcd_static_pod_location }}"
  34. state: directory
  35. owner: "root"
  36. group: "root"
  37. mode: 0700
  38. - name: Write etcd global config file
  39. template:
  40. src: etcd.conf.j2
  41. dest: "{{ etcd_conf_file }}"
  42. backup: true
  43. - name: Create temp directory for static pods
  44. command: mktemp -d /tmp/openshift-ansible-XXXXXX
  45. register: mktemp
  46. changed_when: false
  47. - name: Prepare etcd static pod
  48. copy:
  49. src: "{{ item }}"
  50. dest: "{{ mktemp.stdout }}"
  51. mode: 0600
  52. with_items:
  53. - etcd.yaml
  54. - name: Update etcd static pod
  55. yedit:
  56. src: "{{ mktemp.stdout }}/{{ item }}"
  57. edits:
  58. - key: spec.containers[0].image
  59. value: "{{ etcd_image }}"
  60. with_items:
  61. - etcd.yaml
  62. - name: Set etcd host as a probe target host
  63. yedit:
  64. src: "{{ mktemp.stdout }}/{{ item }}"
  65. edits:
  66. - key: spec.containers[0].livenessProbe.exec.command
  67. value:
  68. - "etcdctl"
  69. - "--cert-file"
  70. - "{{ etcd_peer_cert_file }}"
  71. - "--key-file"
  72. - "{{ etcd_peer_key_file }}"
  73. - "--ca-file"
  74. - "{{ etcd_peer_ca_file }}"
  75. - "-C"
  76. - "{{ etcd_peer_url_scheme }}://{{ etcd_ip }}:{{ etcd_client_port }}"
  77. - "cluster-health"
  78. with_items:
  79. - etcd.yaml
  80. - name: Deploy etcd static pod
  81. copy:
  82. remote_src: true
  83. src: "{{ mktemp.stdout }}/{{ item }}"
  84. dest: "{{ etcd_static_pod_location }}"
  85. mode: 0600
  86. with_items:
  87. - etcd.yaml
  88. - name: Remove temp directory
  89. file:
  90. state: absent
  91. name: "{{ mktemp.stdout }}"
  92. changed_when: False