From ba1ae0a1215f3708934c00b349478eaf221bbae0 Mon Sep 17 00:00:00 2001 From: Aaron Guise Date: Tue, 9 Aug 2022 07:39:06 +1200 Subject: [PATCH] Add samba download option --- tasks/downloads/http/.gitkeep | 0 tasks/downloads/samba/main.yml | 61 ++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 tasks/downloads/http/.gitkeep create mode 100644 tasks/downloads/samba/main.yml diff --git a/tasks/downloads/http/.gitkeep b/tasks/downloads/http/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/tasks/downloads/samba/main.yml b/tasks/downloads/samba/main.yml new file mode 100644 index 0000000..f13f2d5 --- /dev/null +++ b/tasks/downloads/samba/main.yml @@ -0,0 +1,61 @@ +--- +# These tasks will ensure the control node has the correct packages +# for talking Samba. And then download the required package files. +# Note: This is only to pull them to the control node. +# +# Still needs to be pushed to the guest +- name: Ensure Samba-related packages are installed. + package: + name: "{{ item }}" + state: present + with_items: + - samba-client + - cifs-utils + delegate_to: localhost + +- name: Ensure download path is present + file: + path: /tmp/dls + state: directory + delegate_to: localhost + +- name: Set Facts + set_fact: + cmk_download_new: "{{ ( cmk_download_path + '/' + cmk_installer ) | reslash }}" + +- name: Some Vars for debuggery + vars: + msg: | + CMK Download Path: {{ cmk_download_path }} + CMK Download Full: '{{ cmk_download_new }}' + CMK Installer: {{ cmk_installer }} + Username: {{ cmk_smb_username }} + Password: {{ cmk_smb_password }} + debug: + msg: "{{ msg.split('\n') }}" + when: cmk_debug + + +- name: Copy archive from samba_share. (No-Log) + command: > + smbget 'smb:{{ ( cmk_download_path + '/' + cmk_installer ) | reslash }}' + -U '{{ cmk_smb_username }}%{{ cmk_smb_password }}' + args: + chdir: /tmp/dls + creates: /tmp/dls/{{ cmk_installer }} + warn: false # Don't warn of other modules. I want to use smbget ;) + no_log: true # Turn off logging due to password exposure + when: not cmk_debug | bool + delegate_to: localhost + +- name: Copy archive from samba_share. (Debug) + command: > + smbget 'smb:{{ ( cmk_download_path + '/' + cmk_installer ) | reslash }}' + -U '{{ cmk_smb_username | trim }}%{{ cmk_smb_password | trim }}' + args: + chdir: /tmp/dls + creates: /tmp/dls/{{ cmk_installer }} + warn: false # Don't warn of other modules. I want to use smbget ;) + no_log: false # Turn off logging due to password exposure + when: cmk_debug | bool + delegate_to: localhost