mirror of
https://git.ecdf.ed.ac.uk/win_automation/windows-ansible.git
synced 2026-10-26 15:07:21 +00:00
Rework win_tranfer to role from playbook
This commit is contained in:
1 parent
c9b47832e5
commit
a911929a5c
6 files changed
+44
-56
No files matched your search
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- hosts: "meta-name_fs01"
|
||||
# many ansible options set in /etc/ansible/hosts
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../vars/common.yml
|
||||
roles:
|
||||
- role: win_transfer
|
||||
tags: win_transfer
|
||||
@@ -1,56 +0,0 @@
|
||||
---
|
||||
- hosts: "meta-name_fs01"
|
||||
remote_user: skylight-rundeck
|
||||
become: yes
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../vars/common.yml
|
||||
vars:
|
||||
credentials_file: "/root/windows-envs/.{{ os_project }}-{{ win_project }}-smbcredentials"
|
||||
tasks:
|
||||
- name: Configure
|
||||
tags: configure_mount
|
||||
block:
|
||||
- name: Create the mount point
|
||||
file:
|
||||
path: "/mnt/windows/{{ os_project }}-{{ win_project }}"
|
||||
state: directory
|
||||
mode: "0770"
|
||||
owner: sg-transfer
|
||||
group: sg-transfer
|
||||
delegate_to: os-transfer
|
||||
|
||||
- name: Create credential file
|
||||
file:
|
||||
path: "{{ credentials_file }}"
|
||||
state: touch
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0600'
|
||||
delegate_to: os-transfer
|
||||
|
||||
- name: Write username into the credentials file
|
||||
lineinfile:
|
||||
path: "{{ credentials_file }}"
|
||||
line: username=file-transfer@{{ win_project }}.loc
|
||||
create: yes
|
||||
delegate_to: os-transfer
|
||||
|
||||
- name: Write password into the credentials file
|
||||
lineinfile:
|
||||
path: "{{ credentials_file }}"
|
||||
line: password={{ transfer_user_password }}
|
||||
create: yes
|
||||
delegate_to: os-transfer
|
||||
|
||||
- name: Mount Data
|
||||
tags: mount_data
|
||||
block:
|
||||
- name: Mount filesystem on os-transfer
|
||||
ansible.posix.mount:
|
||||
src: "//{{ hostvars[inventory_hostname].ansible_host }}/File_Transfer"
|
||||
path: "/mnt/windows/{{ os_project }}-{{ win_project }}"
|
||||
opts: "credentials={{ credentials_file }},iocharset=utf8"
|
||||
state: mounted
|
||||
fstype: cifs
|
||||
delegate_to: os-transfer
|
||||
@@ -0,0 +1,2 @@
|
||||
---
|
||||
- import_tasks: mount.yml
|
||||
@@ -0,0 +1,29 @@
|
||||
---
|
||||
- name: Setup Mount
|
||||
tags: setup_mount
|
||||
block:
|
||||
- name: Create the mount point
|
||||
file:
|
||||
path: "{{ mount_directory }}"
|
||||
state: directory
|
||||
mode: "0770"
|
||||
owner: sg-transfer
|
||||
group: sg-transfer
|
||||
|
||||
- name: Copy smb-credential template to os-transfer
|
||||
template:
|
||||
dest: "{{ credentials_path }}"
|
||||
src: smb-credentials.j2
|
||||
delegate_to: os-transfer
|
||||
|
||||
- name: Mount Filesystem
|
||||
tags: mount_filesystem
|
||||
block:
|
||||
- name: Mount filesystem on os-transfer
|
||||
ansible.posix.mount:
|
||||
src: "//{{ hostvars[inventory_hostname].ansible_host }}/File_Transfer"
|
||||
path: "{{ mount_directory }}"
|
||||
opts: "credentials={{ credentials_path }},iocharset=utf8"
|
||||
state: mounted
|
||||
fstype: cifs
|
||||
delegate_to: os-transfer
|
||||
@@ -0,0 +1,2 @@
|
||||
username=file-transfer@{{ win_project }}.loc
|
||||
password={{ transfer_user_password }}
|
||||
@@ -0,0 +1,2 @@
|
||||
mount_directory: /mnt/windows/{{ os_project }}-{{ win_project }}
|
||||
credentials_path: /root/windows-envs/.{{ os_project }}-{{ win_project }}-smbcredentials
|
||||
Reference in new issue
Block a user