<commit_before>---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: create the system group
  group:
    name: "{{ repo_service_group_name }}"
    state: "present"
    system: "yes"
  tags:
    - pkg-repo-group

- name: Remove old key file(s) if found
  file:
    path: "{{ item }}"
    state: "absent"
  with_items:
    - "{{ repo_service_home_folder }}/.ssh/authorized_keys"
    - "{{ repo_service_home_folder }}/.ssh/id_rsa"
    - "{{ repo_service_home_folder }}/.ssh/id_rsa.pub"
  when: repo_recreate_keys | bool
  tags:
    - repo-key
    - repo-key-create

- name: Create the nginx system user
  user:
    name: "{{ repo_service_user_name }}"
    group: "{{ repo_service_group_name }}"
    comment: "Nginx repo user"
    shell: "/bin/bash"
    system: "yes"
    createhome: "yes"
    home: "{{ repo_service_home_folder }}"
    generate_ssh_key: "yes"
  tags:
    - pkg-repo-user
    - repo-key
    - repo-key-create

- name: File and directory setup
  file:
    path: "{{ item.path }}"
    state: "{{ item.state }}"
    owner: "{{ item.owner|default('root') }}"
    group: "{{ item.group|default('root') }}"
    mode: "{{ item.mode }}"
  with_items:
    - { path: "{{ repo_service_home_folder }}", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/.ssh", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2700" }
    - { path: "{{ repo_service_home_folder }}/repo", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/links", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/os-releases", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/os-releases/{{ openstack_release }}", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/openstackgit", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/python_packages", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/python_packages/pools", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/pools", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/reports", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "/etc/lsyncd", state: "directory", mode: "0755" }
    - { path: "/var/log/lsyncd", state: "directory", mode: "0755" }
    - { path: "/etc/nginx/sites-enabled/default", state: "absent", mode: "0644" }
  tags:
    - pkg-repo-dirs

- name: Drop NGINX configuration files
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - { src: "nginx.conf.j2", dest: "/etc/nginx/nginx.conf" }
    - { src: "rsyncd.conf.j2", dest: "/etc/rsyncd.conf" }
    - { src: "openstack-slushee.vhost.j2", dest: "/etc/nginx/sites-available/openstack-slushee.vhost" }
  notify:
    - reload nginx
  tags:
    - pkg-repo-nginx
    - pkg-repo-config

- name: Change fcgiwrap GID/UID
  lineinfile:
    dest: "/etc/init.d/fcgiwrap"
    regexp: "{{ item.regexp }}"
    line: "{{ item.line }}"
  with_items:
    - { regexp: "^FCGI_SOCKET_OWNER=", line: 'FCGI_SOCKET_OWNER="{{ repo_service_user_name }}"' }
    - { regexp: "^FCGI_SOCKET_GROUP=", line: 'FCGI_SOCKET_GROUP="{{ repo_service_group_name }}"' }
  notify:<commit_msg>Remove unused python_packages and reports directories<commit_after>---
# Copyright 2014, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: create the system group
  group:
    name: "{{ repo_service_group_name }}"
    state: "present"
    system: "yes"
  tags:
    - pkg-repo-group

- name: Remove old key file(s) if found
  file:
    path: "{{ item }}"
    state: "absent"
  with_items:
    - "{{ repo_service_home_folder }}/.ssh/authorized_keys"
    - "{{ repo_service_home_folder }}/.ssh/id_rsa"
    - "{{ repo_service_home_folder }}/.ssh/id_rsa.pub"
  when: repo_recreate_keys | bool
  tags:
    - repo-key
    - repo-key-create

- name: Create the nginx system user
  user:
    name: "{{ repo_service_user_name }}"
    group: "{{ repo_service_group_name }}"
    comment: "Nginx repo user"
    shell: "/bin/bash"
    system: "yes"
    createhome: "yes"
    home: "{{ repo_service_home_folder }}"
    generate_ssh_key: "yes"
  tags:
    - pkg-repo-user
    - repo-key
    - repo-key-create

- name: File and directory setup
  file:
    path: "{{ item.path }}"
    state: "{{ item.state }}"
    owner: "{{ item.owner|default('root') }}"
    group: "{{ item.group|default('root') }}"
    mode: "{{ item.mode }}"
  with_items:
    - { path: "{{ repo_service_home_folder }}", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/.ssh", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2700" }
    - { path: "{{ repo_service_home_folder }}/repo", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/links", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/os-releases", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/os-releases/{{ openstack_release }}", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/openstackgit", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "{{ repo_service_home_folder }}/repo/pools", state: "directory", owner: "{{ repo_service_user_name }}", group: "{{ repo_service_group_name }}", mode: "2755" }
    - { path: "/etc/lsyncd", state: "directory", mode: "0755" }
    - { path: "/var/log/lsyncd", state: "directory", mode: "0755" }
    - { path: "/etc/nginx/sites-enabled/default", state: "absent", mode: "0644" }
  tags:
    - pkg-repo-dirs

- name: Drop NGINX configuration files
  template:
    src: "{{ item.src }}"
    dest: "{{ item.dest }}"
  with_items:
    - { src: "nginx.conf.j2", dest: "/etc/nginx/nginx.conf" }
    - { src: "rsyncd.conf.j2", dest: "/etc/rsyncd.conf" }
    - { src: "openstack-slushee.vhost.j2", dest: "/etc/nginx/sites-available/openstack-slushee.vhost" }
  notify:
    - reload nginx
  tags:
    - pkg-repo-nginx
    - pkg-repo-config

- name: Change fcgiwrap GID/UID
  lineinfile:
    dest: "/etc/init.d/fcgiwrap"
    regexp: "{{ item.regexp }}"
    line: "{{ item.line }}"
  with_items:
    - { regexp: "^FCGI_SOCKET_OWNER=", line: 'FCGI_SOCKET_OWNER="{{ repo_service_user_name }}"' }
    - { regexp: "^FCGI_SOCKET_GROUP=", line: 'FCGI_SOCKET_GROUP="{{ repo_service_group_name }}"' }
  notify:
{'fraction_non_alphanumeric': 0.17465328672905625, 'fraction_numerical': 0.013755778554515728, 'mean_word_length': 3.8180336773492667, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, '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': '5909485', 'n_tokens_mistral': 3222, 'n_tokens_neox': 3091, 'n_words': 695}