|
@@ -0,0 +1,96 @@
|
|
|
|
+---
|
|
|
|
+- name: Inform what is going on
|
|
|
|
+ pause:
|
|
|
|
+ prompt: |-
|
|
|
|
+ *************************************************************************************
|
|
|
|
+ Checking if {{ item.name }} needs to be processed...
|
|
|
|
+ *************************************************************************************
|
|
|
|
+ seconds: 0
|
|
|
|
+
|
|
|
|
+- name: Get download confirmation code from Google Drive
|
|
|
|
+ uri:
|
|
|
|
+ url: "https://drive.google.com/uc?export=download&id={{ item.file_id }}"
|
|
|
|
+ creates: "{{ ansible_facts['user_dir'] }}/Downloads/{{ item.name }}"
|
|
|
|
+ return_content: yes
|
|
|
|
+ status_code: 200
|
|
|
|
+ register: dl_cc
|
|
|
|
+ when: not (item.direct_download | default(true))
|
|
|
|
+
|
|
|
|
+- name: Store conf code as a fact
|
|
|
|
+ set_fact:
|
|
|
|
+ src_url: "{{ dl_cc.content | regex_replace('^.*action=\"', '') | regex_replace('\".*$', '') | regex_replace('amp;', '') }}"
|
|
|
|
+ when: dl_cc.content is defined
|
|
|
|
+
|
|
|
|
+- name: Store direct URL as a fact
|
|
|
|
+ set_fact:
|
|
|
|
+ src_url: "https://drive.google.com/uc?export=download&id={{ item.file_id }}"
|
|
|
|
+ when:
|
|
|
|
+ - dl_cc.content is not defined
|
|
|
|
+ - item.direct_download | default(true)
|
|
|
|
+
|
|
|
|
+- name: Check if the target dir is already there
|
|
|
|
+ ansible.builtin.stat:
|
|
|
|
+ path: "{{ item.target_dir }}"
|
|
|
|
+ register: targetdir
|
|
|
|
+ when: item.target_dir is defined
|
|
|
|
+
|
|
|
|
+- name: Download the file
|
|
|
|
+ get_url:
|
|
|
|
+ url: "{{ src_url }}"
|
|
|
|
+ dest: "{{ ansible_facts['user_dir'] }}/Downloads/{{ item.name }}"
|
|
|
|
+ mode: 0664
|
|
|
|
+ timeout: 30
|
|
|
|
+ checksum: "{{ item.checksum | default('') }}"
|
|
|
|
+ when:
|
|
|
|
+ - (src_url | default(None)) != None
|
|
|
|
+ - item.target_dir is not defined or (targetdir.stat is defined and not targetdir.stat.exists)
|
|
|
|
+ register: downloaded
|
|
|
|
+
|
|
|
|
+- name: Extract if so required
|
|
|
|
+ become: yes
|
|
|
|
+ unarchive:
|
|
|
|
+ src: "{{ ansible_facts['user_dir'] }}/Downloads/{{ item.name }}"
|
|
|
|
+ remote_src: yes
|
|
|
|
+ creates: "{{ item.extracted_dir }}"
|
|
|
|
+ dest: "{{ item.extract_to | default('/') }}"
|
|
|
|
+ register: extract_action
|
|
|
|
+ when:
|
|
|
|
+ - item.extracted_dir is defined
|
|
|
|
+ - downloaded.changed
|
|
|
|
+
|
|
|
|
+- name: Rename wherever the archive extracted to whatever new name is required, if so
|
|
|
|
+ become: yes
|
|
|
|
+ command: mv {{ item.extracted_dir }} {{ item.target_dir }}
|
|
|
|
+ when:
|
|
|
|
+ - item.target_dir is defined
|
|
|
|
+ - extract_action is defined
|
|
|
|
+ - extract_action.changed
|
|
|
|
+
|
|
|
|
+- name: Make sure bin is in PATH
|
|
|
|
+ lineinfile:
|
|
|
|
+ path: "{{ ansible_facts['user_dir'] }}/.bashrc"
|
|
|
|
+ line: 'PATH="${PATH}:{{ item.target_dir | default(item.extracted_dir) }}/bin"'
|
|
|
|
+ regexp: '^PATH=.*{{ item.target_dir | default(item.extracted_dir) }}/bin'
|
|
|
|
+ insertafter: "^# User specific environment$"
|
|
|
|
+ state: present
|
|
|
|
+ when:
|
|
|
|
+ - item.add_to_path is defined
|
|
|
|
+ - item.add_to_path
|
|
|
|
+ - item.extracted_dir is defined
|
|
|
|
+
|
|
|
|
+- name: Remove after finished if so required
|
|
|
|
+ file:
|
|
|
|
+ path: "{{ ansible_facts['user_dir'] }}/Downloads/{{ item.name }}"
|
|
|
|
+ state: absent
|
|
|
|
+ when:
|
|
|
|
+ - item.remove_after is defined
|
|
|
|
+ - item.remove_after
|
|
|
|
+
|
|
|
|
+- name: reset facts
|
|
|
|
+ set_fact:
|
|
|
|
+ dl_cc: !!null
|
|
|
|
+ src_url: !!null
|
|
|
|
+ targetdir: !!null
|
|
|
|
+ downloaded: !!null
|
|
|
|
+ extract_action: !!null
|
|
|
|
+...
|