static.yml 2.0 KB

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