Cisco.ios VLAN trunk config error

Hi, I’m trying to configure a Cisco Catalyst 1000 switch. but I’m receiving an error that isn’t clear.

I am able to create VLANs on the switch using the examples from the documentation.

Now I’m trying to configure a switchport as a trunk port and apply the vlans, it fails. I’ve used the example code from the module page as a start point, but cannot get it to work.

My playbook:

   - name: Configure Trunk on Port 1 
     become: true                                                                        
     cisco.ios.ios_l2_interfaces:
       config:
         - name: GigabitEthernet1/0/1
           mode: trunk
           trunk:
             allowed_vlans: 10,20,30,40
             encapsulation: "dot1q"
      state: replaced

However, I’m given this error:

TASK [Configure Trunk on Port 1] **********************************************************************************
task path: /home/andrew/ansible/repo/switch/configure.yaml:93
Loading collection ansible.netcommon from /home/andrew/ansible/lib/python3.13/site-packages/ansible_collections/ansible/netcommon
Loading collection ansible.utils from /home/andrew/ansible/lib/python3.13/site-packages/ansible_collections/ansible/utils
<10.0.0.40> Using network group action cisco.ios.ios for cisco.ios.ios_l2_interfaces
<10.0.0.40> attempting to start connection
<10.0.0.40> using connection plugin ansible.netcommon.network_cli
<10.0.0.40> found existing local domain socket, using it!
<10.0.0.40> updating play_context for connection
<10.0.0.40> Loading collection ansible.builtin from 
<10.0.0.40> local domain socket path is /home/andrew/.ansible/pc/cda46402ca
<10.0.0.40> ANSIBLE_NETWORK_IMPORT_MODULES: enabled
<10.0.0.40> ANSIBLE_NETWORK_IMPORT_MODULES: found cisco.ios.ios_l2_interfaces  at /home/andrew/ansible/lib/python3.13/site-packages/ansible_collections/cisco/ios/plugins/modules/ios_l2_interfaces.py
<10.0.0.40> ANSIBLE_NETWORK_IMPORT_MODULES: running cisco.ios.ios_l2_interfaces
<10.0.0.40> ANSIBLE_NETWORK_IMPORT_MODULES: complete
fatal: [catalyst1000]: FAILED! => {
    "changed": false,
    "module_stderr": "switchport trunk encapsulation dot1q\r\nswitchport trunk encapsulation dot1q\r\n                 ^\r\n% Invalid input detected at '^' marker.\r\n\r\nCatalyst1000(config-if)#",
    "module_stdout": "",
    "msg": "MODULE FAILURE: No start of json char found\nSee stdout/stderr for the exact error"
}

I don’t understand what the error means, and can’t find anything online that helps me either. Can anyone here help?

Ansible version: 2.18.2
Python: 3.13.1
cisco.ios module 9.1.0
IOS version: 5.2(7r)E

Oh well, it was as simple as deleting the encapsulation: "dot1q" line. I thought that I’d tried with & without that before posting.