<commit_before>---
- include: sync_kube_master_certs.yml
  when: inventory_hostname in groups['kube-master']

- include: sync_kube_node_certs.yml
  when: inventory_hostname in groups['k8s-cluster']

# Issue admin certs to kube-master hosts
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    issue_cert_common_name: "admin"
    issue_cert_copy_ca: "{{ item == kube_admin_certs_needed|first }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['kube-master'] }}"
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-master
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_admin_certs_needed|d([]) }}"
  when: inventory_hostname in groups['kube-master']

- name: gen_certs_vault | Set fact about certificate alt names
  set_fact:
    kube_cert_alt_names: >-
      {{
      groups['kube-master'] +
      ['kubernetes.default.svc.cluster.local', 'kubernetes.default.svc', 'kubernetes.default', 'kubernetes'] +
      ['localhost']
      }}
  run_once: true

- name: gen_certs_vault | Add external load balancer domain name to certificate alt names
  set_fact:
    kube_cert_alt_names: "{{ kube_cert_alt_names + [apiserver_loadbalancer_domain_name] }}"
  when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
  run_once: true

# Issue master components certs to kube-master hosts
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    issue_cert_common_name: "kubernetes"
    issue_cert_alt_names: "{{ kube_cert_alt_names }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['kube-master'] }}"
    issue_cert_ip_sans: >-
        [
        {%- for host in groups['kube-master']  -%}
        "{{ hostvars[host]['ansible_default_ipv4']['address'] }}",
        {%- if hostvars[host]['ip'] is defined -%}
        "{{ hostvars[host]['ip'] }}",
        {%- endif -%}
        {%- endfor -%}
        "127.0.0.1","::1","{{ kube_apiserver_ip }}"
        ]
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-master
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_master_components_certs_needed|d([]) }}"
  when: inventory_hostname in groups['kube-master']
  notify: set secret_changed

# Issue node certs to k8s-cluster nodes
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    issue_cert_common_name: "system:node:{{ item.rsplit('/', 1)[1].rsplit('.', 1)[0] }}"
    issue_cert_copy_ca: "{{ item == kube_node_certs_needed|first }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['k8s-cluster'] }}"
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-node
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_node_certs_needed|d([]) }}"
  when: inventory_hostname in groups['k8s-cluster']
<commit_msg>Updating CN for node certs generated by vault (#1622)<commit_after>---
- include: sync_kube_master_certs.yml
  when: inventory_hostname in groups['kube-master']

- include: sync_kube_node_certs.yml
  when: inventory_hostname in groups['k8s-cluster']

# Issue admin certs to kube-master hosts
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    issue_cert_common_name: "admin"
    issue_cert_copy_ca: "{{ item == kube_admin_certs_needed|first }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['kube-master'] }}"
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-master
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_admin_certs_needed|d([]) }}"
  when: inventory_hostname in groups['kube-master']

- name: gen_certs_vault | Set fact about certificate alt names
  set_fact:
    kube_cert_alt_names: >-
      {{
      groups['kube-master'] +
      ['kubernetes.default.svc.cluster.local', 'kubernetes.default.svc', 'kubernetes.default', 'kubernetes'] +
      ['localhost']
      }}
  run_once: true

- name: gen_certs_vault | Add external load balancer domain name to certificate alt names
  set_fact:
    kube_cert_alt_names: "{{ kube_cert_alt_names + [apiserver_loadbalancer_domain_name] }}"
  when: loadbalancer_apiserver is defined and apiserver_loadbalancer_domain_name is defined
  run_once: true

# Issue master components certs to kube-master hosts
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    issue_cert_common_name: "kubernetes"
    issue_cert_alt_names: "{{ kube_cert_alt_names }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['kube-master'] }}"
    issue_cert_ip_sans: >-
        [
        {%- for host in groups['kube-master']  -%}
        "{{ hostvars[host]['ansible_default_ipv4']['address'] }}",
        {%- if hostvars[host]['ip'] is defined -%}
        "{{ hostvars[host]['ip'] }}",
        {%- endif -%}
        {%- endfor -%}
        "127.0.0.1","::1","{{ kube_apiserver_ip }}"
        ]
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-master
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_master_components_certs_needed|d([]) }}"
  when: inventory_hostname in groups['kube-master']
  notify: set secret_changed

# Issue node certs to k8s-cluster nodes
- include: ../../../vault/tasks/shared/issue_cert.yml
  vars:
    # Need to strip out the 'node-' prefix from the cert name so it can be used
    # with the node authorization plugin ( CN matches kubelet node name )
    issue_cert_common_name: "system:node:{{ item.rsplit('/', 1)[1].rsplit('.', 1)[0] | regex_replace('^node-', '') }}"
    issue_cert_copy_ca: "{{ item == kube_node_certs_needed|first }}"
    issue_cert_file_group: "{{ kube_cert_group }}"
    issue_cert_file_owner: kube
    issue_cert_hosts: "{{ groups['k8s-cluster'] }}"
    issue_cert_path: "{{ item }}"
    issue_cert_role: kube-node
    issue_cert_url: "{{ hostvars[groups.vault|first]['vault_leader_url'] }}"
    issue_cert_mount_path: "{{ kube_vault_mount_path }}"
  with_items: "{{ kube_node_certs_needed|d([]) }}"
  when: inventory_hostname in groups['k8s-cluster']

{'fraction_non_alphanumeric': 0.1513415737111848, 'fraction_numerical': 0.005426590292432921, 'mean_word_length': 4.15139751552795, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7243432', 'n_tokens_mistral': 2445, 'n_tokens_neox': 2380, 'n_words': 395}