<commit_before>---
- name: update apt
  apt: >
    update_cache=yes
    cache_valid_time=3600
  when: ansible_os_family == "Debian"

- name: install deps (Debian)
  apt: >
    pkg={{item}}
    state=present
  with_items:
    - unzip
  when: ansible_os_family == "Debian"

- name: fail with Fedora 22+
  fail: msg="Fedora 22+ is not supported yet because it uses dnf"
  when: ansible_distribution == "Fedora" and ansible_distribution_major_version|int >= 22

- name: install deps (RedHat)
  yum: >
    pkg={{ item }}
    state=present
  with_items:
    - unzip
  when: ansible_os_family == "RedHat"

- name: create consul-template directory structure
  file: >
    state=directory
    path={{ item }}
  with_items:
    - "{{ consul_template_home }}"
    - "{{ consul_template_home }}/bin"
    - "{{ consul_template_home }}/config"
    - "{{ consul_template_home }}/templates"

- name: check archive stat
  stat: path={{ consul_template_staging_area }}/{{ consul_template_archive_file }}
  register: consul_template_archive_stat

- name: download consul-template binary
  get_url:
    url: "{{ consul_template_download_url }}"
    dest: "{{ consul_template_staging_area }}"
  when: consul_template_archive_stat.stat.exists == False

- name: unzip the downloaded package
  unarchive:
    src: "{{ consul_template_staging_area }}/{{ consul_template_archive_file }}"
    dest: "{{ consul_template_staging_area }}"
    owner: "root"
    group: "root"
    copy: False
    creates: "{{ consul_template_staging_area }}/{{ consul_template_binary }}"

- name: copy consul-template binary into place
  command: cp {{ consul_template_staging_area }}/{{ consul_template_binary }} {{ consul_template_home }}/bin/{{ consul_template_binary }}
    creates={{ consul_template_home }}/bin/{{ consul_template_binary }}

- name: Update consul-template permissions
  file:
    path: "{{ consul_template_home }}/bin/{{ consul_template_binary }}"
    owner: "root"
    group: "root"
    mode: "0755"

- name: copy consul-template systemd service configuration
  template: >
    src=consul-template.service.systemd.j2
    dest=/etc/systemd/system/consul-template.service
    mode=0755
  when: consul_template_use_systemd

- name: copy consul-template upstart service configuration
  template: >
    src=consul-template.service.upstart.j2
    dest=/etc/init/consul-template.conf
    mode=0755
  when: consul_template_use_upstart

- name: copy consul-template init.d script
  template: >
    src={{consul_template_initd_template}}
    dest=/etc/init.d/consul-template
    owner=root
    group=root
    mode=0755
  when: consul_template_use_initd

- name: add consul-template to path through profile.d
  template: >
    src=consul-template.sh.j2
    dest=/etc/profile.d/consul-template.sh
    owner=root
    group=root
    mode=0755

- name: consul-template config file
  template: >
    src={{ consul_template_config_file_template }}
    dest={{ consul_template_home }}/config/{{ consul_template_config_file }}
    mode=0755

- name: copy template files
  copy: src="{{ item.src }}" dest="{{ consul_template_home }}/templates/{{ item.src | basename }}"
  with_items: "{{ consul_template_template_files }}"
  when: consul_template_template_files
  notify: restart consul-template

- name: copy template templates
  template: src={{ item.src }} dest="{{ consul_template_home }}/templates/{{ item.dest if item.dest is defined else item.src | basename | regex_replace('^(.*)\.j2$', '\\1') }}"
  with_items: "{{ consul_template_template_templates | default([]) }}"
  when: consul_template_template_templates
  notify: restart consul-template<commit_msg>Remove default as it is already in the default file Update apt and yum usage to avoid deprecation messages Add a strict check over template installation conditions<commit_after>---
- name: update apt
  apt: >
    update_cache=yes
    cache_valid_time=3600
  when: ansible_os_family == "Debian"

- name: install deps (Debian)
  apt: >
    pkg=unzip
    state=present
  when: ansible_os_family == "Debian"

- name: fail with Fedora 22+
  fail: msg="Fedora 22+ is not supported yet because it uses dnf"
  when: ansible_distribution == "Fedora" and ansible_distribution_major_version|int >= 22

- name: install deps (RedHat)
  yum: >
    pkg=unzip
    state=present
  when: ansible_os_family == "RedHat"

- name: create consul-template directory structure
  file: >
    state=directory
    path={{ item }}
  with_items:
    - "{{ consul_template_home }}"
    - "{{ consul_template_home }}/bin"
    - "{{ consul_template_home }}/config"
    - "{{ consul_template_home }}/templates"

- name: check archive stat
  stat: path={{ consul_template_staging_area }}/{{ consul_template_archive_file }}
  register: consul_template_archive_stat

- name: download consul-template binary
  get_url:
    url: "{{ consul_template_download_url }}"
    dest: "{{ consul_template_staging_area }}"
  when: consul_template_archive_stat.stat.exists == False

- name: unzip the downloaded package
  unarchive:
    src: "{{ consul_template_staging_area }}/{{ consul_template_archive_file }}"
    dest: "{{ consul_template_staging_area }}"
    owner: "root"
    group: "root"
    copy: False
    creates: "{{ consul_template_staging_area }}/{{ consul_template_binary }}"

- name: copy consul-template binary into place
  command: cp {{ consul_template_staging_area }}/{{ consul_template_binary }} {{ consul_template_home }}/bin/{{ consul_template_binary }}
    creates={{ consul_template_home }}/bin/{{ consul_template_binary }}

- name: Update consul-template permissions
  file:
    path: "{{ consul_template_home }}/bin/{{ consul_template_binary }}"
    owner: "root"
    group: "root"
    mode: "0755"

- name: copy consul-template systemd service configuration
  template: >
    src=consul-template.service.systemd.j2
    dest=/etc/systemd/system/consul-template.service
    mode=0755
  when: consul_template_use_systemd

- name: copy consul-template upstart service configuration
  template: >
    src=consul-template.service.upstart.j2
    dest=/etc/init/consul-template.conf
    mode=0755
  when: consul_template_use_upstart

- name: copy consul-template init.d script
  template: >
    src={{consul_template_initd_template}}
    dest=/etc/init.d/consul-template
    owner=root
    group=root
    mode=0755
  when: consul_template_use_initd

- name: add consul-template to path through profile.d
  template: >
    src=consul-template.sh.j2
    dest=/etc/profile.d/consul-template.sh
    owner=root
    group=root
    mode=0755

- name: consul-template config file
  template: >
    src={{ consul_template_config_file_template }}
    dest={{ consul_template_home }}/config/{{ consul_template_config_file }}
    mode=0755

- name: copy template files
  copy: src="{{ item.src }}" dest="{{ consul_template_home }}/templates/{{ item.src | basename }}"
  with_items: "{{ consul_template_template_files }}"
  when: consul_template_template_files | length > 0
  notify: restart consul-template

- name: copy template templates
  template: src={{ item.src }} dest="{{ consul_template_home }}/templates/{{ item.dest if item.dest is defined else item.src | basename | regex_replace('^(.*)\.j2$', '\\1') }}"
  with_items: "{{ consul_template_template_templates }}"
  when: consul_template_template_templates | length > 0
  notify: restart consul-template
{'fraction_non_alphanumeric': 0.1199945518932171, 'fraction_numerical': 0.010896213565785889, 'mean_word_length': 4.124214933705513, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1602327', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2439, 'n_words': 537}