Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

nmcli dns example does not run #1910

Closed
varesa opened this issue Mar 25, 2016 · 10 comments
Closed

nmcli dns example does not run #1910

varesa opened this issue Mar 25, 2016 · 10 comments

Comments

@varesa
Copy link

varesa commented Mar 25, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

nmcli

ANSIBLE VERSION
ansible 2.0.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION

n/a

OS / ENVIRONMENT

CentOS 7 / CentOS 7

SUMMARY

nmcli example for setting two dns servers is invalid syntax and does not run.

# To add two IPv4 DNS server addresses:
-nmcli: conn_name=my-eth1 dns4=["8.8.8.8", "8.8.4.4"] state=present
STEPS TO REPRODUCE

Create playbook based on example from http://docs.ansible.com/ansible/nmcli_module.html


---
- hosts: all
  remote_user: root
  tasks:
  - nmcli: conn_name=eth0 dns4=["8.8.8.8", "8.8.4.4"] state=present

EXPECTED RESULTS

Task runs ok, dns servers get set

ACTUAL RESULTS
ERROR! this task 'nmcli' has extra params, which is only allowed in the following modules: command, shell, script, include, include_vars, add_host, group_by, set_fact, raw, meta

The error appears to have been in '/root/ansible_playbooks/common.yaml': line 5, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

  tasks:
  - nmcli: conn_name=eth0 dns4=["8.8.8.8", "8.8.4.4"] state=present
    ^ here
We could be wrong, but this one looks like it might be an issue with
unbalanced quotes.  If starting a value with a quote, make sure the
line ends with the same set of quotes.  For instance this arbitrary
example:

    foo: "bad" "wolf"

Could be written as:

    foo: '"bad" "wolf"'

@DerekL
Copy link

DerekL commented Apr 12, 2016

I'm having the same issue. nmcli docs don't have the comma in between dns servers:

https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Networking_Guide/sec-Using_the_NetworkManager_Command_Line_Tool_nmcli.html

Leaving out the comma and using single quotes:

  • nmcli: conn_name=eth0 ifname=eno16780032 dns4=['8.8.8.8 8.8.4.4'] state=present

    changes the error to:

fatal: [linux238.app.ansible]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"ageingtime": "300", "arp_interval": null, "arp_ip_target": null, "autoconnect": null, "conn_name": "eth0", "dns4": "["8.8.8.8 8.8.4.4"]", "dns6": null, "downdelay": null, "egress": null, "flags": null, "forwarddelay": "15", "gw4": "192.168.10.254", "gw6": null, "hellotime": "2", "ifname": "eno16780032", "ingress": null, "ip4": "192.168.10.238/24", "ip6": null, "mac": null, "master": null, "maxage": "20", "miimon": null, "mode": "balance-rr", "mtu": null, "priority": "128", "slavepriority": "32", "state": "present", "stp": "yes", "type": "ethernet", "updelay": null, "vlandev": null, "vlanid": null}, "module_name": "nmcli"}, "msg": "Error: failed to modify ipv4.dns: invalid IPv4 address '["8.8.8.8'.\n", "name": "eth0", "rc": 2}
fatal: [linux239.app.ansible]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"ageingtime": "300", "arp_interval": null, "arp_ip_target": null, "autoconnect": null, "conn_name": "eth0", "dns4": "["8.8.8.8 8.8.4.4"]", "dns6": null, "downdelay": null, "egress": null, "flags": null, "forwarddelay": "15", "gw4": "192.168.10.254", "gw6": null, "hellotime": "2", "ifname": "eno16780032", "ingress": null, "ip4": "192.168.10.239/24", "ip6": null, "mac": null, "master": null, "maxage": "20", "miimon": null, "mode": "balance-rr", "mtu": null, "priority": "128", "slavepriority": "32", "state": "present", "stp": "yes", "type": "ethernet", "updelay": null, "vlandev": null, "vlanid": null}, "module_name": "nmcli"}, "msg": "Error: failed to modify ipv4.dns: invalid IPv4 address '["8.8.8.8'.\n", "name": "eth0", "rc": 2}

After some brute forcing with different formats: It works if you leave out the brackets:

- nmcli: conn_name=eth0 dns4="8.8.8.8, 8.8.4.4" state=present

@ansibot
Copy link

ansibot commented Aug 4, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Sep 13, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Oct 6, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

2 similar comments
@ansibot
Copy link

ansibot commented Oct 22, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Nov 6, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

@iredmail
Copy link

This issue still occur with Ansible-2.2.

@ansibot
Copy link

ansibot commented Nov 22, 2016

@alcamie101, ping. This issue is still waiting on your response.
click here for bot help

@ansibot
Copy link

ansibot commented Dec 7, 2016

This repository has been locked. All new issues and pull requests should be filed in https://github.com/ansible/ansible

Please read through the repomerge page in the dev guide. The guide contains links to tools which automatically move your issue or pull request to the ansible/ansible repo.

@rossmobi
Copy link

rossmobi commented Jan 12, 2017

Still happening. Anyone hoping to resolve this?

I'd note that it only really happens when the DNS entries are on a line of their own.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants