【问题标题】:ansible nmcli for Raspbian 10用于 Raspbian 10 的 ansible nmcli
【发布时间】:2021-12-16 15:16:11
【问题描述】:

使用 Ansible,我正在尝试配置一个刚刚使用 Raspbian 10 映像的 Raspberry Pi。

其中一项任务是设置网络。我正在尝试使用community.general.nmcli,但到目前为止没有成功:

- hosts: all

  tasks:

    - name: update and upgrade apt packages
      become: true
      apt:
        upgrade: dist
        update_cache: true

    - name: Install network manager
      become: true
      apt:
        name: network-manager
        state: present

    # see https://gist.github.com/truh/de723a3bc0f837f75d3673ddf101e108 and
    # https://raspberrypi.stackexchange.com/a/73816/137489
    - name: Uninstall openresolv and dhcpcd5
      become: true
      apt:
        pkg:
        - openresolve
        - dhcpcd5
        state: absent
        purge: yes

    - name: configure network
      become: true
      community.general.nmcli:
        state: present
        conn_name: my-eth0
        ifname: eth0
        type: ethernet
        ip4: 192.168.1.2/24
        gw4: 192.168.1.1

前三个任务对应:

sudo apt update
sudo apt install network-manager
sudo apt purge openresolv dhcpcd5

按照this gistthis discussion 的建议。

前 3 个任务允许我在(RPi 的)命令行上使用 nmcli

但是,第四个任务(使用community.general.nmcli)失败了:

fatal: [192.168.1.2]: FAILED! => {"changed": false, "msg": "Error: invalid property 'routing-rules': 'routing-rules' not among [method, dns, dns-search, dns-options, dns-priority, addresses, gateway, routes, route-metric, route-table, ignore-auto-routes, ignore-auto-dns, dhcp-client-id, dhcp-timeout, dhcp-send-hostname, dhcp-hostname, dhcp-fqdn, never-default, may-fail, dad-timeout].\n", "name": "my-eth0", "rc": 2}

有没有办法让 Ansible 的 community.general.nmcli 在 Raspbian 10 上工作?

【问题讨论】:

    标签: ansible raspbian


    【解决方案1】:

    这是由于 Raspbian 在 1.18 版本之前使用 NetworkManager,此时功能 routing-rules was released。否则不会有问题,但是,Ansible nmcli 模块希望在尝试创建接口时该参数存在,但随后 nmcli 失败并显示此奇怪消息。

    已经有一个未解决的问题:https://github.com/ansible-collections/community.general/issues/3948

    【讨论】:

      猜你喜欢
      • 2017-11-30
      • 1970-01-01
      • 2023-02-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-10
      • 2019-10-18
      • 1970-01-01
      相关资源
      最近更新 更多