Raspbian 10 的 ansible nmcli
ansible nmcli for Raspbian 10
使用 Ansible,我正在尝试提供一个 Raspberry Pi 刚用 Raspbian 10.
拍摄的图像
其中一项任务是设置网络。我正在尝试使用 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 gist and this 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 上工作?
这是由于 Raspbian 使用 NetworkManager 1.18 之前的版本,这是功能 routing-rules
was released 时的结果。否则这不会成为问题,但是,Ansible nmcli
模块在尝试创建接口时期望此参数存在,但随后 nmcli
失败并显示此奇怪的消息。
已经有一个未解决的问题:https://github.com/ansible-collections/community.general/issues/3948
使用 Ansible,我正在尝试提供一个 Raspberry Pi 刚用 Raspbian 10.
拍摄的图像其中一项任务是设置网络。我正在尝试使用 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 gist and this 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 上工作?
这是由于 Raspbian 使用 NetworkManager 1.18 之前的版本,这是功能 routing-rules
was released 时的结果。否则这不会成为问题,但是,Ansible nmcli
模块在尝试创建接口时期望此参数存在,但随后 nmcli
失败并显示此奇怪的消息。
已经有一个未解决的问题:https://github.com/ansible-collections/community.general/issues/3948