# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

- name: Print network interfaces
  ansible.builtin.debug:
    msg: 'allNetworkInterfaces: {{ ansible_interfaces }}'
  tags:
  - vlan-setup

- name: Update NetworkManager interfaces
  ansible.builtin.copy:
    src: files/10-globally-managed-devices.conf
    dest: /etc/NetworkManager/conf.d/10-globally-managed-devices.conf
    owner: root
    group: root
    mode: '0644'
  tags:
  - vlan-setup

- name: Reload service network-manager, pre VLAN creation
  ansible.builtin.service:
    name: network-manager
    state: reloaded
  tags:
  - vlan-setup

- name: Add VLAN interface 410 in linux
  nmcli:
    type: vlan
    conn_name: '{{ prinetint }}.410'
    method4: auto
    vlanid: '410'
    vlandev: '{{ prinetint }}'
    state: present
  tags:
  - vlan-setup

- name: Reload service network-manager, post VLAN creation
  ansible.builtin.service:
    name: network-manager
    state: reloaded
  tags:
  - vlan-setup

- name: Print network interfaces
  ansible.builtin.debug:
    msg: 'allNetworkInterfaces: {{ ansible_interfaces }}'
  tags:
  - vlan-setup
