title: How to use ansible to switch vlans on a Juniper Switch
body: <p>I am using a variant of the example provided <a href="https://docs.ansible.com/ansible/latest/collections/junipernetworks/junos/junos_l2_interfaces_module.html#ansible-collections-junipernetworks-junos-junos-l2-interfaces-module" rel="nofollow noreferrer">junipernetworks.junos.junos_l2_interfaces – L2 interfaces resource module</a></p>
  <p>My playbook</p>
  <pre><code>- name: Switch VLAN
    hosts: all
    connection: local
    tasks:
      - name: Replace VLAN
        junipernetworks.junos.junos_l2_interfaces:
          config:
            - name: xe-0/0/16
              access:
                vlan: 100
          state: replaced
  </code></pre>
  <p>Output from Ansible:</p>
  <pre><code>[WARNING]: ['connection local support for this module is deprecated and will be removed in version 2.14, use connection ansible.netcommon.netconf']
  fatal: [10.70.44.76]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Unsupported parameters for (junipernetworks.junos.junos_l2_interfaces) module: provider Supported parameters include: config, running_config, state&quot;}
  </code></pre>
  <p>So I updated the connection type to use netconf as recommend by the warning (and enabled netconf on the switch)</p>
  <p>Updated Playbook:</p>
  <pre><code>- name: Switch VLAN
    hosts: all
    connection: ansible.netcommon.netconf
    tasks:
      - name: Replace VLAN
        junipernetworks.junos.junos_l2_interfaces:
          config:
            - name: xe-0/0/16
              access:
                vlan: 100
          state: replaced
  </code></pre>
  <p>Results in a Failed play but cryptic message</p>
  <pre><code>fatal: [10.70.44.76]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;b'None'&quot;}
  </code></pre>
  <p>So next I tried their persistent connection:</p>
  <pre><code>- name: Switch VLAN
    hosts: all
    connection: juniper.device.pyez
    tasks:
      - name: Replace VLAN
        junipernetworks.junos.junos_l2_interfaces:
          config:
            - name: xe-0/0/16
              access:
                vlan: 100
          state: replaced
  </code></pre>
  <p>Results in a 3rd error!</p>
  <pre><code>fatal: [10.70.44.76]: FAILED! =&gt; {&quot;changed&quot;: false, &quot;msg&quot;: &quot;Method not found&quot;}
  </code></pre>
  <p>Anything else I am missing or can try?</p>