<commit_before>#      _            _                                       
#   __| | ___ _ __ | | ___  _   _       _   _ ___  ___ _ __ 
#  / _` |/ _ \ '_ \| |/ _ \| | | |_____| | | / __|/ _ \ '__|
# | (_| |  __/ |_) | | (_) | |_| |_____| |_| \__ \  __/ |   
#  \__,_|\___| .__/|_|\___/ \__, |      \__,_|___/\___|_|   
#            |_|            |___/                           
- hosts: all
  become: True
  become_user: root
  remote_user: root
  vars:
    conf:
      home: /home
    user:
      username: deploy
      password: <PASSWORD>
      group: deploy
      uid: 400
      gid: 400
  tasks:
    - name: deploy-user | Group for deployment should be created
      group: >
        name={{ user.username }}
        gid={{ user.gid }}
        state=present

    - name: deploy-user | User for deployment should be created
      user: >
        name={{ user.username }}
        uid={{ user.uid }}
        group={{ user.group }}
        groups=wheel
        shell=/bin/sh
        home={{ conf.home }}/{{ user.username }}
        password={{ user.password }}
        createhome=yes
        state=present

    - name: deploy-user | Linux | sudoers.d/deploy has been created
      when: ansible_system == "Linux"
      shell: >
        chdir=/etc/sudoers.d
        creates=deploy
        printf "Defaults secure_path = '%s'\n%%%s ALL=NOPASSWD%s ALL\n"
        '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
        {{ user.group }} : | tr "'" '"' > deploy

    - name: deploy-user | Linux | sudoers.d/deploy is 0440
      when: ansible_system == "Linux"
      file: path=/etc/sudoers.d/deploy mode=0440 state=file

    - name: deploy-user | FreeBSD | sudoers.d/deploy has been created
      when: ansible_os_family == "FreeBSD"
      shell: >
        chdir=/usr/local/etc/sudoers.d
        creates=deploy
        printf "Defaults secure_path = '%s'\n%%%s ALL=NOPASSWD%s ALL\n"
        '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
        {{ user.group }} : | tr "'" '"' > deploy

    - name: deploy-user | FreeBSD | sudoers.d/deploy is 0440
      when: ansible_os_family == "FreeBSD"
      file: path=/usr/local/etc/sudoers.d/deploy mode=0440 state=file

    - name: deploy-user | OpenBSD | Check /etc/sudoers
      when: ansible_system == "OpenBSD"
      shell: grep %{{ user.group }} /etc/sudoers
      register: sudoers
      ignore_errors: True
      changed_when: sudoers.rc == 1

    - name: deploy user | {{ user.group }} should be registered in /etc/sudoers
      when: sudoers.changed
      ignore_errors: True
      shell: >
        printf "%%%s ALL=NOPASSWD%s ALL\n" {{ user.group }} : >> /etc/sudoers

    - name: deploy-user | Authorized key should be deployed
      authorized_key: >
        user={{ user.username }}
        key="{{ lookup('file', '../.ssh/id2-deploy-rsa.pub') }}"

<commit_msg>Fix task name<commit_after>#      _            _                                       
#   __| | ___ _ __ | | ___  _   _       _   _ ___  ___ _ __ 
#  / _` |/ _ \ '_ \| |/ _ \| | | |_____| | | / __|/ _ \ '__|
# | (_| |  __/ |_) | | (_) | |_| |_____| |_| \__ \  __/ |   
#  \__,_|\___| .__/|_|\___/ \__, |      \__,_|___/\___|_|   
#            |_|            |___/                           
- hosts: all
  become: True
  become_user: root
  remote_user: root
  vars:
    conf:
      home: /home
    user:
      username: deploy
      password: <PASSWORD>
      group: deploy
      uid: 400
      gid: 400
  tasks:
    - name: deploy-user | Group for deployment should be created
      group: >
        name={{ user.username }}
        gid={{ user.gid }}
        state=present

    - name: deploy-user | User for deployment should be created
      user: >
        name={{ user.username }}
        uid={{ user.uid }}
        group={{ user.group }}
        groups=wheel
        shell=/bin/sh
        home={{ conf.home }}/{{ user.username }}
        password={{ <PASSWORD> }}
        createhome=yes
        state=present

    - name: deploy-user | Linux | sudoers.d/deploy has been created
      when: ansible_system == "Linux"
      shell: >
        chdir=/etc/sudoers.d
        creates=deploy
        printf "Defaults secure_path = '%s'\n%%%s ALL=NOPASSWD%s ALL\n"
        '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
        {{ user.group }} : | tr "'" '"' > deploy

    - name: deploy-user | Linux | sudoers.d/deploy is 0440
      when: ansible_system == "Linux"
      file: path=/etc/sudoers.d/deploy mode=0440 state=file

    - name: deploy-user | FreeBSD | sudoers.d/deploy has been created
      when: ansible_os_family == "FreeBSD"
      shell: >
        chdir=/usr/local/etc/sudoers.d
        creates=deploy
        printf "Defaults secure_path = '%s'\n%%%s ALL=NOPASSWD%s ALL\n"
        '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
        {{ user.group }} : | tr "'" '"' > deploy

    - name: deploy-user | FreeBSD | sudoers.d/deploy is 0440
      when: ansible_os_family == "FreeBSD"
      file: path=/usr/local/etc/sudoers.d/deploy mode=0440 state=file

    - name: deploy-user | OpenBSD | Check /etc/sudoers
      when: ansible_system == "OpenBSD"
      shell: grep %{{ user.group }} /etc/sudoers
      register: sudoers
      ignore_errors: True
      changed_when: sudoers.rc == 1

    - name: deploy-user | {{ user.group }} should be registered in /etc/sudoers
      when: sudoers.changed
      ignore_errors: True
      shell: >
        printf "%%%s ALL=NOPASSWD%s ALL\n" {{ user.group }} : >> /etc/sudoers

    - name: deploy-user | Authorized key should be deployed
      authorized_key: >
        user={{ user.username }}
        key="{{ lookup('file', '../.ssh/id2-deploy-rsa.pub') }}"


{'fraction_non_alphanumeric': 0.15392725355824988, 'fraction_numerical': 0.008434370057986295, 'mean_word_length': 1.8346613545816732, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3594455', 'n_tokens_mistral': 2025, 'n_tokens_neox': 1887, 'n_words': 375}