【发布时间】: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 gist 和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 上工作?
【问题讨论】: