Skip to content

Instantly share code, notes, and snippets.

@densogiaichned
Created October 18, 2022 05:22
Show Gist options
  • Save densogiaichned/491668e14bb3dd34a1ff363ea840334e to your computer and use it in GitHub Desktop.
Save densogiaichned/491668e14bb3dd34a1ff363ea840334e to your computer and use it in GitHub Desktop.
Install TwinCAT with Ansible
# Install TwinCAT on a remote Windows machine.
# Files to upload from {{upload_dir}}, i.e.:
# - TC31-FULL-Setup.3.1.4024.35.exe
# - PsExec.exe (see https://learn.microsoft.com/en-us/sysinternals/downloads/psexec)
---
- name: Install TwinCAT
hosts: all
vars:
user_temp: ''
upload_dir: .install-files/
tasks:
- name: Get the temp-directory of current user
ansible.builtin.win_shell: echo %temp%
args:
executable: cmd
register: cmd_output
- name: Set user-temp folder variable
ansible.builtin.set_fact:
user_temp: '{{ cmd_output.stdout | trim }}\~install-files'
- name: Upload installation files
ansible.builtin.win_copy:
src: '{{ upload_dir }}'
dest: '{{ user_temp }}'
directory_mode:
- name: Install TwinCAT3
ansible.builtin.win_psexec:
chdir: '{{ user_temp }}'
executable: '{{ user_temp }}\PsExec.exe'
command: cmd /c START /B /WAIT TC31-FULL-Setup.3.1.4024.35.exe /clone_wait /s /v"/qr REBOOT=ReallySuppress ALLUSERS=1 /l*v logs\TC31-install.log"
interactive: true
session: 1
system: true
- name: Download TC3 installation log file
ansible.builtin.fetch:
src: '{{ user_temp }}\TC31-install.log'
dest: ./~logs/{{ ansible_hostname }}/TC31-install.log
flat: true
- name: Remove temp-directory
ansible.builtin.win_file:
path: '{{ user_temp }}'
state: absent
@densogiaichned
Copy link
Author

NOTE
The TwinCAT installer needs UI (interactive mode), despite having silent option enabled.
Thus, this playbook uses win_psexec, all other methods failed.
This was the only way to get TwinCAT installed properly.

See also Beckhoff Infosys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment