<commit_before>---
# This file is included both in the openshift_master role and in the upgrade
# playbooks.  For that reason the ha_svc variables are use set_fact instead of
# the vars directory on the role.

- name: Init HA Service Info
  set_fact:
    containerized_svc_dir: "/usr/lib/systemd/system"
    ha_svc_template_path: "native-cluster"

- name: Set HA Service Info for containerized installs
  set_fact:
    containerized_svc_dir: "/etc/systemd/system"
    ha_svc_template_path: "docker-cluster"
  when: openshift.common.is_containerized | bool

# This is the image used for both HA and non-HA clusters:
- name: Pre-pull master image
  command: >
    docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  register: pull_result
  changed_when: "'Downloaded newer image' in pull_result.stdout"
  when: openshift.common.is_containerized | bool and not openshift.common.is_master_system_container | bool

# workaround for missing systemd unit files
- name: Create the systemd unit files
  template:
    src: "master_docker/master.docker.service.j2"
    dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master.service"
  when:
  - openshift.common.is_containerized | bool and (openshift.master.ha is not defined or not openshift.master.ha) | bool
  - not openshift.common.is_master_system_container | bool
  register: create_master_unit_file

- command: systemctl daemon-reload
  when: create_master_unit_file | changed

- name: Create the ha systemd unit files
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
    dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  when:
  - openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  - not openshift.common.is_master_system_container | bool
  with_items:
  - api
  - controllers
  register: create_ha_unit_files

- command: systemctl daemon-reload
  when: create_ha_unit_files | changed
# end workaround for missing systemd unit files

- name: Preserve Master API Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: master_api_proxy
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Preserve Master API AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: master_api_aws
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Create the master api service env file
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    backup: true
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  notify:
  - restart master api

- name: Restore Master API Proxy Config Options
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
      and master_api_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ master_api_proxy.stdout_lines | default([]) }}"

- name: Restore Master API AWS Options
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
      and master_api_aws.rc == 0 and
      not (openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined)
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ master_api_aws.stdout_lines | default([]) }}"

- name: Preserve Master Controllers Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_proxy
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Preserve Master Controllers AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_aws
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Create the master controllers service env file
  template:<commit_msg>Stop logging AWS credentials in master role.<commit_after>---
# This file is included both in the openshift_master role and in the upgrade
# playbooks.  For that reason the ha_svc variables are use set_fact instead of
# the vars directory on the role.

- name: Init HA Service Info
  set_fact:
    containerized_svc_dir: "/usr/lib/systemd/system"
    ha_svc_template_path: "native-cluster"

- name: Set HA Service Info for containerized installs
  set_fact:
    containerized_svc_dir: "/etc/systemd/system"
    ha_svc_template_path: "docker-cluster"
  when: openshift.common.is_containerized | bool

# This is the image used for both HA and non-HA clusters:
- name: Pre-pull master image
  command: >
    docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  register: pull_result
  changed_when: "'Downloaded newer image' in pull_result.stdout"
  when: openshift.common.is_containerized | bool and not openshift.common.is_master_system_container | bool

# workaround for missing systemd unit files
- name: Create the systemd unit files
  template:
    src: "master_docker/master.docker.service.j2"
    dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master.service"
  when:
  - openshift.common.is_containerized | bool and (openshift.master.ha is not defined or not openshift.master.ha) | bool
  - not openshift.common.is_master_system_container | bool
  register: create_master_unit_file

- command: systemctl daemon-reload
  when: create_master_unit_file | changed

- name: Create the ha systemd unit files
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
    dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  when:
  - openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  - not openshift.common.is_master_system_container | bool
  with_items:
  - api
  - controllers
  register: create_ha_unit_files

- command: systemctl daemon-reload
  when: create_ha_unit_files | changed
# end workaround for missing systemd unit files

- name: Preserve Master API Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: master_api_proxy
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Preserve Master API AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: master_api_aws
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Create the master api service env file
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    backup: true
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  notify:
  - restart master api

- name: Restore Master API Proxy Config Options
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
      and master_api_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ master_api_proxy.stdout_lines | default([]) }}"

- name: Restore Master API AWS Options
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
      and master_api_aws.rc == 0 and
      not (openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined)
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  no_log: True

- name: Preserve Master Controllers Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_proxy
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Preserve Master Controllers AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_aws
  when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  failed_when: false
  changed_when: false

- name: Create the master controllers service env file
  template:
{'fraction_non_alphanumeric': 0.09172441907867916, 'fraction_numerical': 0.0010191602119853241, 'mean_word_length': 4.562925170068027, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2132238', 'n_tokens_mistral': 3130, 'n_tokens_neox': 3005, 'n_words': 857}