<commit_before>#####################
# CentOS
- include: centos.yml
  when: ansible_distribution == 'CentOS'

#####################
# Ubuntu
- include: ubuntu.yml
  when: ansible_distribution == 'Ubuntu'

#####################
# Debian
- include: debian.yml
  when: ansible_distribution == 'Debian'

#####################
# Common
- name: "Make sure the required node version is installed"
  shell: |
    creates={{ node_dir }}
    . /opt/nvm/nvm.sh && nvm install {{ node_version }}
  tags:
    - statsd
    - nodejs

- name: "Create a statsd system user"
  user: >
    name=statsd
    shell=/bin/false
    createhome=no
    state=present
  tags:
    - statsd
    - users

- name: "Download the StatsD repo from GitHub"
  git: >
    repo=https://github.com/etsy/statsd.git
    dest={{ statsd_path }}
    update=yes
    version=v0.6.0
  tags:
    - statsd
    - pkgs

- name: "Install required StatsD backends"
  shell: |
    chdir={{ statsd_path }}

    source {{ nvm_dir }}/nvm.sh
    nvm use {{ node_version }}
    {{ npm_path }} install {{ item }}
  with_items:
    - statsd-librato-backend
    - statsd-instrumental-backend
    - statsd-ducksboard-backend
    - js-yaml
  tags:
    - statsd
    - pkgs

- name: "Install statsd init.d script"
  template: >
    src=statsd.init.sh.j2
    dest=/etc/init.d/statsd
    owner=statsd
    group=statsd
    mode=0700
  notify:
    - Restart StatsD
  tags:
    - statsd
    - files

- name: "Make sure /etc/statsd exists"
  file: >
    path=/etc/statsd
    state=directory
    owner=statsd
    group=statsd
    mode=0700
  tags:
    - statsd
    - files
    - configs

- name: "Install StatsD config file"
  template: >
    src=config.js.j2
    dest=/etc/statsd/config.js
    owner=statsd
    group=statsd
    mode=0600
  tags:
    - statsd
    - files
    - configs
  notify:
    - Restart StatsD

- name: "Set StatsD runlevel and ensure its running"
  service: >
    name=statsd
    state=running
    enabled=yes
    runlevel=5
  tags:
    - statsd

- name: "Add the statsd firewall rules file"
  template: >
    src=iptables-statsd.j2
    dest=/etc/iptables.d/statsd
    mode=0600
    backup=no
    owner=root
    group=root
  tags:
    - statsd
    - firewall
    - files

- name: "Apply the statsd firewall rules right now"
  shell: |
    /sbin/iptables-restore -v --noflush < /etc/iptables.d/statsd
  tags:
    - statsd
    - firewall

- name: "Add /etc/aeriscloud.d service definition"
  template: >
    src=aeriscloud-statsd.j2
    dest=/etc/aeriscloud.d/statsd
    mode=0644
    backup=no<commit_msg>Ensure the /etc/aeriscloud.d directory is created each time e need it<commit_after>#####################
# CentOS
- include: centos.yml
  when: ansible_distribution == 'CentOS'

#####################
# Ubuntu
- include: ubuntu.yml
  when: ansible_distribution == 'Ubuntu'

#####################
# Debian
- include: debian.yml
  when: ansible_distribution == 'Debian'

#####################
# Common
- name: "Make sure the required node version is installed"
  shell: |
    creates={{ node_dir }}
    . /opt/nvm/nvm.sh && nvm install {{ node_version }}
  tags:
    - statsd
    - nodejs

- name: "Create a statsd system user"
  user: >
    name=statsd
    shell=/bin/false
    createhome=no
    state=present
  tags:
    - statsd
    - users

- name: "Download the StatsD repo from GitHub"
  git: >
    repo=https://github.com/etsy/statsd.git
    dest={{ statsd_path }}
    update=yes
    version=v0.6.0
  tags:
    - statsd
    - pkgs

- name: "Install required StatsD backends"
  shell: |
    chdir={{ statsd_path }}

    source {{ nvm_dir }}/nvm.sh
    nvm use {{ node_version }}
    {{ npm_path }} install {{ item }}
  with_items:
    - statsd-librato-backend
    - statsd-instrumental-backend
    - statsd-ducksboard-backend
    - js-yaml
  tags:
    - statsd
    - pkgs

- name: "Install statsd init.d script"
  template: >
    src=statsd.init.sh.j2
    dest=/etc/init.d/statsd
    owner=statsd
    group=statsd
    mode=0700
  notify:
    - Restart StatsD
  tags:
    - statsd
    - files

- name: "Make sure /etc/statsd exists"
  file: >
    path=/etc/statsd
    state=directory
    owner=statsd
    group=statsd
    mode=0700
  tags:
    - statsd
    - files
    - configs

- name: "Install StatsD config file"
  template: >
    src=config.js.j2
    dest=/etc/statsd/config.js
    owner=statsd
    group=statsd
    mode=0600
  tags:
    - statsd
    - files
    - configs
  notify:
    - Restart StatsD

- name: "Set StatsD runlevel and ensure its running"
  service: >
    name=statsd
    state=running
    enabled=yes
    runlevel=5
  tags:
    - statsd

- name: "Add the statsd firewall rules file"
  template: >
    src=iptables-statsd.j2
    dest=/etc/iptables.d/statsd
    mode=0600
    backup=no
    owner=root
    group=root
  tags:
    - statsd
    - firewall
    - files

- name: "Apply the statsd firewall rules right now"
  shell: |
    /sbin/iptables-restore -v --noflush < /etc/iptables.d/statsd
  tags:
    - statsd
    - firewall

- name: "Ensure the aeriscloud.d directory exists"
  file: >
    path=/etc/aeriscloud.d
    state=directory
    mode=0755
    owner=root
    group=root
  tags:
    - statsd
    - files
    - announce

- name: "Add /etc/aeriscloud.d service definition"
  template: >
    src=aeriscloud-statsd.j2
    dest=/etc/aeriscloud.d/statsd
    mode=0644
    backup=no
{'fraction_non_alphanumeric': 0.13979496738117428, 'fraction_numerical': 0.011183597390493943, 'mean_word_length': 2.4048223350253806, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 2, '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': '5850652', 'n_tokens_mistral': 2017, 'n_tokens_neox': 1917, 'n_words': 431}