Transfer file witch ansible.builtin.expect

Hello,

I try to automate the installation of OpnSense to a proxmox cluster. The inital configuration of OpnSense does not match my network configuration and therefore I only have a virtual serial terminal for configuring (until SSH is available).
Beside a few commands I need to transfer the initial configuration file with the correct network and ssh setup.
Currently I create a python script thats modify the config.xml of OpnSense, but this looks a little bit messy:

    - name: Apply initial configuration settings
      delegate_to: pve1
      ansible.builtin.expect:
        command: "qm terminal {{ proxmox_id }}"
        timeout: 5
        echo: true
        responses:
          'starting serial terminal on interface serial0': ''
          'root@OPNsense:':
            - 'cat <<EOF > test.py'
            - 'python3 test.py'
            - '/usr/local/etc/rc.reload_all' # Apply configuration
            - "\x0F"  # = CTRL-O
          '\?':
            - import xml.etree.ElementTree as ET
            - import xml, uuid
            - conf_file = '/conf/config.xml'
           # ... much more lines

Any idea, how to transfer a local existing config file via the expect module?

Thanks a lot for your help!

done. Solved it with a virtual USB Stick for file transfer.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.