<commit_before>---
- name: configure initial iRODS resource tree
  hosts: [irods_ies]
  tasks: 

  - name: check if demoResc is passthru
    shell: "iadmin lr demoResc | grep resc_type_name | awk '{print $2;}'"
    register: demoResc_type

  - debug: var=demoResc_type.stdout_lines[0]

  - name: delete default demoResc if its type is 'unixfilesystem' 
    command: iadmin rmresc demoResc
    register: demoResc_removed
    when: demoResc_type.stdout_lines[0] == 'unixfilesystem'

  - name: select all default _hostname_Resource to delete
    shell: ilsresc | grep -e .*Resource
    register: default_resources

  - debug: var=default_resources.stdout_lines

  - name: delete all default _hostname_Resource resources
    shell: iadmin rmresc {{ item }}
    with_items:
    - '{{ default_resources.stdout_lines }}'

  - name: create 'passthru' demoResc
    command: iadmin mkresc demoResc 'passthru'
    when: demoResc_removed | changed

<commit_msg>initial irods resc tree done<commit_after>---
# Creates initial iRODS resc tree structure
#
# $ ilsresc --tree
# demoResc:passthru
# └── replResc:replication
#     ├── host1_resc
#     └── host2_resc
#
#
- name: configure initial iRODS resource tree
  hosts: [irods_ies]
  tasks: 

  - name: check if demoResc is passthru
    shell: "iadmin lr demoResc | grep resc_type_name | awk '{print $2;}'"
    register: demoResc_type

  - debug: var=demoResc_type.stdout_lines[0]

  - name: delete default demoResc if its type is 'unixfilesystem' 
    command: iadmin rmresc demoResc
    register: demoResc_removed
    when: demoResc_type.stdout_lines[0] == 'unixfilesystem'

  - name: find all default _hostname_Resource to delete
    shell: ilsresc | grep -e .*Resource
    register: find_default_resources
    # grep will exit with 1 when no results found. 
    # This causes the task not to halt play.
    ignore_errors: true

  - debug: var=default_resources

  - name: delete all default _hostname_Resource resources
    shell: iadmin rmresc {{ item }}
    with_items:
    - '{{ find_default_resources.stdout_lines }}'
    when: not find_default_resources | failed

  - name: create 'passthru' demoResc
    command: iadmin mkresc demoResc 'passthru'
    when: demoResc_removed | changed

  - name: find 'replResc' 
    shell: ilsresc | grep replResc 
    register: find_replResc
    # grep will exit with 1 when no results found. 
    # This causes the task not to halt play.
    ignore_errors: true

  - debug: var=find_replResc

  - name: create 'replResc' if it doesn't exist
    command: "{{ item }}"
    with_items:
    - "iadmin mkresc replResc 'replication'"
    - "iadmin addchildtoresc demoResc replResc"
    when: find_replResc | failed

  - name: find all _hostname__resc resources to add them to the 'replResc'
    shell: ilsresc | grep -e .*_resc
    register: resources

  - debug: resources

  - name: add _hostname__resc to 'replResc'
    command: iadmin addchildtoresc replResc {{ item }}
    with_items:
    - "{{ resources.stdout_lines }}"


{'fraction_non_alphanumeric': 0.0875207986688852, 'fraction_numerical': 0.0033277870216306157, 'mean_word_length': 3.4205882352941175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5252870', 'n_tokens_mistral': 1015, 'n_tokens_neox': 1008, 'n_words': 299}