bootstrap.yml.j2 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. {% raw %}
  2. #!/usr/bin/ansible-playbook
  3. ---
  4. - hosts: localhost
  5. gather_facts: yes
  6. vars:
  7. origin_dns:
  8. file: /etc/dnsmasq.d/origin-dns.conf
  9. lines:
  10. - regex: ^listen-address
  11. state: present
  12. line: "listen-address={{ ansible_default_ipv4.address }}"
  13. node_dns:
  14. file: /etc/dnsmasq.d/node-dnsmasq.conf
  15. lines:
  16. - regex: "^server=/in-addr.arpa/127.0.0.1$"
  17. line: server=/in-addr.arpa/127.0.0.1
  18. - regex: "^server=/cluster.local/127.0.0.1$"
  19. line: server=/cluster.local/127.0.0.1
  20. tasks:
  21. - include_vars: openshift_settings.yaml
  22. - name: set the data for node_dns
  23. lineinfile:
  24. create: yes
  25. insertafter: EOF
  26. path: "{{ node_dns.file }}"
  27. regexp: "{{ item.regex }}"
  28. line: "{{ item.line | default(omit) }}"
  29. with_items: "{{ node_dns.lines }}"
  30. - name: set the data for origin_dns
  31. lineinfile:
  32. create: yes
  33. state: "{{ item.state | default('present') }}"
  34. insertafter: "{{ item.after | default(omit) }}"
  35. path: "{{ origin_dns.file }}"
  36. regexp: "{{ item.regex }}"
  37. line: "{{ item.line | default(omit)}}"
  38. with_items: "{{ origin_dns.lines }}"
  39. - when:
  40. - openshift_group_type is defined
  41. - openshift_group_type != ''
  42. - openshift_group_type != 'master'
  43. block:
  44. - name: determine the openshift_service_type
  45. stat:
  46. path: /etc/sysconfig/atomic-openshift-node
  47. register: service_type_results
  48. - name: set openshift_service_type fact based on stat results
  49. set_fact:
  50. openshift_service_type: "{{ service_type_results.stat.exists | ternary('atomic-openshift', 'origin') }}"
  51. - name: update the sysconfig to have necessary variables
  52. lineinfile:
  53. dest: "/etc/sysconfig/{{ openshift_service_type }}-node"
  54. line: "{{ item.line }}"
  55. regexp: "{{ item.regexp }}"
  56. with_items:
  57. - line: "BOOTSTRAP_CONFIG_NAME=node-config-{{ openshift_group_type }}"
  58. regexp: "^BOOTSTRAP_CONFIG_NAME=.*"
  59. {% endraw %}
  60. {% if openshift_cloudprovider_kind | default('') == 'aws' %}
  61. # need to update aws.conf file if the instance has come up in a new region
  62. - name: set up aws.conf
  63. block:
  64. - name: get current AZ
  65. uri:
  66. url: http://169.254.169.254/latest/meta-data/placement/availability-zone
  67. return_content: yes
  68. register: aws_out
  69. - name: set AZ in aws.conf
  70. ini_file:
  71. path: /etc/origin/cloudprovider/aws.conf
  72. section: Global
  73. option: Zone
  74. value: "{% raw %}{{ aws_out.content }}{% endraw %}"
  75. {% endif %}