bootstrap.yml.j2 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. tasks:
  14. - include_vars: openshift_settings.yaml
  15. - name: set the data for origin_dns
  16. lineinfile:
  17. create: yes
  18. state: "{{ item.state | default('present') }}"
  19. insertafter: "{{ item.after | default(omit) }}"
  20. path: "{{ origin_dns.file }}"
  21. regexp: "{{ item.regex }}"
  22. line: "{{ item.line | default(omit)}}"
  23. with_items: "{{ origin_dns.lines }}"
  24. - when:
  25. - openshift_node_config_name is defined
  26. - openshift_node_config_name != ''
  27. block:
  28. - name: determine the openshift_service_type
  29. stat:
  30. path: /etc/sysconfig/atomic-openshift-node
  31. get_checksum: false
  32. get_attributes: false
  33. get_mime: false
  34. register: service_type_results
  35. - name: set openshift_service_type fact based on stat results
  36. set_fact:
  37. openshift_service_type: "{{ service_type_results.stat.exists | ternary('atomic-openshift', 'origin') }}"
  38. - name: update the sysconfig to have necessary variables
  39. lineinfile:
  40. dest: "/etc/sysconfig/{{ openshift_service_type }}-node"
  41. line: "{{ item.line }}"
  42. regexp: "{{ item.regexp }}"
  43. with_items:
  44. - line: "BOOTSTRAP_CONFIG_NAME={{ openshift_node_config_name }}"
  45. regexp: "^BOOTSTRAP_CONFIG_NAME=.*"
  46. {% endraw %}
  47. {% if openshift_cloudprovider_kind | default('') == 'aws' %}
  48. # need to update aws.conf file if the instance has come up in a new region
  49. - name: set up aws.conf
  50. block:
  51. - name: get current AZ
  52. uri:
  53. url: http://169.254.169.254/latest/meta-data/placement/availability-zone
  54. return_content: yes
  55. register: aws_out
  56. - name: set AZ in aws.conf
  57. ini_file:
  58. path: /etc/origin/cloudprovider/aws.conf
  59. section: Global
  60. option: Zone
  61. value: "{% raw %}{{ aws_out.content }}{% endraw %}"
  62. {% endif %}