<commit_before>---

- name: Create xvfb_mount context and PT uncompressing folder
  file: path="{{ docker_context_uncompressed_installation }}" state=directory


- name: Update and copy Dockerfile for adding PT
  template:
    src: "Dockerfile_mount_pt.j2"
    dest: "{{ xvfb_ptmount_context }}/Dockerfile"
  tags:
   - template
   - copy
   - files
   - docker


- name: Uncompress installation files
  shell: "tar zxvf {{ xvfb_ptadd_context }}/{{ compressed_installation_file.name }} -C {{ docker_context_uncompressed_installation }}"
#  unarchive:
#    src: "{{ compressed_installation_file.name }}"
#    dest: "{{ compressed_installation_file.decompressed }}"
#    creates: yes
#    copy: no
  tags:
   - uncompress
   - installation
   - files
   - packetTracer


- name: Move PT main folder to appropriate path
  shell: "{{ item }}"
  become: True
  with_items:
    - "rm -rf {{ compressed_installation_file.folders[0].original }}"
    - "mv {{ docker_context_uncompressed_installation }}/{{ compressed_installation_file.folders[0].backup }} {{ compressed_installation_file.folders[0].original }}"


- name: Change ownership of the installation folder
  file:
    path: "{{ compressed_installation_file.folders[0].original }}"
    owner: "{{ remote_user }}"
    group: "{{ remote_group }}"
  become: True


- name: Build docker container automatically
  shell: "docker build --rm -t {{ docker_xvfb_ptmount_image }} {{ xvfb_ptmount_context }}"
  ignore_errors: True
  register: container_build
  tags:
   - build
   - container
   - docker


- name: Add 'packettracer' tag
  shell: "docker tag  -f {{ docker_xvfb_ptmount_image }} {{ docker_image }}"
  when: container_build.rc != 1
  ignore_errors: True
  register: container_build
  tags:
   - container
   - docker
   - tag


- name: Build docker container manually
  debug: msg="{{ item }}"
  when: container_build.rc == 1
  with_items:
    - "docker build --rm -t {{ docker_xvfb_ptmount_image }} {{ xvfb_ptmount_context }}"
    - "docker tag {{ docker_xvfb_ptmount_image }} {{ docker_image }}"


- name: Remove temporary folder
  file: path="{{ compressed_installation_file.decompressed }}" state=absent


- name: Reminder to run image built
  debug: msg="docker run -p 5901:{{ docker_vnc_port }} -p 39000:{{ docker_pt_port }} -ti {{ docker_image }} -v {{ compressed_installation_file.folders[0].original }}:{{ compressed_installation_file.folders[0].original }}"
  when: not include_pt<commit_msg>Mounting PT main folder from a data-only container instead of from the host (issue #3).<commit_after>---

- name: Create xvfb_mount context and PT uncompressing folder
  file: path="{{ docker_context_uncompressed_installation }}" state=directory


- name: Update and copy Dockerfile for adding PT
  template:
    src: "Dockerfile_mount_pt.j2"
    dest: "{{ xvfb_ptmount_context }}/Dockerfile"
  tags:
   - template
   - copy
   - files
   - docker


- name: Uncompress installation files
  shell: "tar zxvf {{ xvfb_ptadd_context }}/{{ compressed_installation_file.name }} -C {{ docker_context_uncompressed_installation }}"
#  unarchive:
#    src: "{{ compressed_installation_file.name }}"
#    dest: "{{ compressed_installation_file.decompressed }}"
#    creates: yes
#    copy: no
  tags:
   - uncompress
   - installation
   - files
   - packetTracer


- name: Remove unused PT main folder (it will be mounted from a data-only container)
  shell: "{{ item }}"
  become: True
  with_items:
    - "rm -rf {{ docker_context_uncompressed_installation }}/{{ compressed_installation_file.folders[0].backup }}"


- name: Build docker container automatically
  shell: "docker build --rm -t {{ docker_xvfb_ptmount_image }} {{ xvfb_ptmount_context }}"
  ignore_errors: True
  register: container_build
  tags:
   - build
   - container
   - docker


- name: Add 'packettracer' tag
  shell: "docker tag  -f {{ docker_xvfb_ptmount_image }} {{ docker_image }}"
  when: container_build.rc != 1
  ignore_errors: True
  register: container_build
  tags:
   - container
   - docker
   - tag


- name: Build docker container manually
  debug: msg="{{ item }}"
  when: container_build.rc == 1
  with_items:
    - "docker build --rm -t {{ docker_xvfb_ptmount_image }} {{ xvfb_ptmount_context }}"
    - "docker tag {{ docker_xvfb_ptmount_image }} {{ docker_image }}"


- name: Remove temporary folder
  file: path="{{ compressed_installation_file.decompressed }}" state=absent


- name: Reminder to run image built
  debug: msg="docker run --volumes-from {{ data_container }} -p 5901:{{ docker_vnc_port }} -p 39000:{{ docker_pt_port }} -ti {{ docker_image }}"
  when: not include_pt
{'fraction_non_alphanumeric': 0.12056277056277057, 'fraction_numerical': 0.006926406926406926, 'mean_word_length': 3.8286311389759664, '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': '7052725', 'n_tokens_mistral': 1581, 'n_tokens_neox': 1487, 'n_words': 373}