<commit_before>#                                               ___            _        
#   ___ ___  _ __ ___  _ __ ___   ___  _ __    / / |_ __ _ ___| | _____ 
#  / __/ _ \| '_ ` _ \| '_ ` _ \ / _ \| '_ \  / /| __/ _` / __| |/ / __|
# | (_| (_) | | | | | | | | | | | (_) | | | |/ / | || (_| \__ \   <\__ \
#  \___\___/|_| |_| |_|_| |_| |_|\___/|_| |_/_/   \__\__,_|___/_|\_\___/
#                                                                       
# adding-swap
- name: adding-swap | Calculate swap space size
  register: swap0
  changed_when: swap0.rc < 0
  shell: echo '( {{ ansible_memtotal_mb }} / 2 * 1024 )' | bc

- name: adding-swap | /swapfile exists
  when: swap0|success
  register: swap1
  ignore_errors: True
  shell: swapon -s | grep /swapfile > /dev/null 2>&1

- name: adding-swap | Prepare swapfile
  when: swap1|failed and ansible_memtotal_mb < {{ config.useswap }}
  register: swap2
  command: >
    chdir=/
    creates=/swapfile
    dd if=/dev/zero of=/swapfile bs=1024 count={{ swap0.stdout }}

- name: adding-swap | Make swapfile
  when: swap2.changed
  register: swap3 
  ignore_errors: True
  command: mkswap /swapfile 
      
- name: adding-swap | Swap on
  when: swap1|failed and swap3|success
  ignore_errors: True
  command: swapon /swapfile
<commit_msg>Add chagend_when parameter<commit_after>#                                               ___            _        
#   ___ ___  _ __ ___  _ __ ___   ___  _ __    / / |_ __ _ ___| | _____ 
#  / __/ _ \| '_ ` _ \| '_ ` _ \ / _ \| '_ \  / /| __/ _` / __| |/ / __|
# | (_| (_) | | | | | | | | | | | (_) | | | |/ / | || (_| \__ \   <\__ \
#  \___\___/|_| |_| |_|_| |_| |_|\___/|_| |_/_/   \__\__,_|___/_|\_\___/
#                                                                       
# adding-swap
- name: adding-swap | Calculate swap space size
  register: swap0
  changed_when: swap0.rc < 0
  shell: echo '( {{ ansible_memtotal_mb }} / 2 * 1024 )' | bc

- name: adding-swap | /swapfile exists
  when: swap0|success
  register: swap1
  changed_when: swap1.rc == 255
  ignore_errors: True
  shell: swapon -s | grep /swapfile > /dev/null 2>&1

- name: adding-swap | Prepare swapfile
  when: swap1|failed and config.useswap == True and ansible_memtotal_mb < {{ config.swapmem }}
  register: swap2
  command: >
    chdir=/
    creates=/swapfile
    dd if=/dev/zero of=/swapfile bs=1024 count={{ swap0.stdout }}

- name: adding-swap | Make swapfile
  when: swap2.changed
  register: swap3 
  changed_when: swap2.rc == 0
  ignore_errors: True
  command: mkswap /swapfile 
      
- name: adding-swap | Swap on
  when: swap1|failed and swap3|success
  register: swap4
  changed_when: swap4.rc == 0
  ignore_errors: True
  command: swapon /swapfile

{'fraction_non_alphanumeric': 0.15, 'fraction_numerical': 0.02022058823529412, 'mean_word_length': 1.8022657054582905, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6528864', 'n_tokens_mistral': 999, 'n_tokens_neox': 951, 'n_words': 180}