I'm using the src parameter of nxos_config to enter several configuration 
lines at once.  When it detects that one of the lines differs from the 
running configuration,  does it push the entire block from the src file or 
just the line that was different?   Also is there any way to display the 
line or lines that were updated in Ansible?  

My test playbook looks like this:

---
- hosts: evpn_leaf
  vars:
    cli:
      host: "{{ inventory_hostname }}"
      username: admin
      password: cisco
      transport: cli


  tasks:



    - name: Send configuration commands from file to switch

      nxos_config:
        provider: "{{ cli }}"
        src: config.txt
      register: result


    - name: Display the result of the task

      debug: var=result verbosity=0


The config.txt file has these lines:

router eigrp 200


interface Ethernet1/48
  description testing2
  no switchport 
  ip address 1.1.1.1/24


router bgp 65000




Every time I run this,  I get a changed result and configuration is 
applied.  I think the reason is that 'no switchport' is a default 
configuration and does not appear in the running configuration on the 
switch.  In this case is Ansible just applying the 'no switchport' command, 
 or all of the config commands in the config.txt file?   Is there any way 
to display in Ansible the config lines that were applied?   

Here is the output...

TASK [Send configuration commands from file to switch] 
******************************************
task path: /home/admin/Ansible/testing/nxos_config.yml:30
Using module file /usr/lib/python2.7/site-packages/ansible/modules/core/
network/nxos/nxos_config.py
<10.255.138.13> ESTABLISH LOCAL CONNECTION FOR USER: admin
<10.255.138.13> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
$HOME/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268 `" && echo 
ansible-tmp-1478630353.51-201030415116268="` echo 
$HOME/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268 `" ) && sleep 
0'
<10.255.138.13> PUT /tmp/tmp0Fdxkn TO /home/admin/.ansible/tmp/ansible-tmp-
1478630353.51-201030415116268/nxos_config.py
<10.255.138.13> EXEC /bin/sh -c 'chmod u+x 
/home/admin/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268/ 
/home/admin/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268/nxos_config.py
 
&& sleep 0'
<10.255.138.13> EXEC /bin/sh -c '/usr/bin/python 
/home/admin/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268/nxos_config.py;
 
rm -rf 
"/home/admin/.ansible/tmp/ansible-tmp-1478630353.51-201030415116268/" > 
/dev/null 2>&1 && sleep 0'
changed: [10.255.138.13] => {
    "changed": true, 
    "invocation": {
        "module_args": {
            "after": null, 
            "auth_pass": null, 
            "authorize": false, 
            "backup": false, 
            "before": null, 
            "config": null, 
            "defaults": false, 
            "force": false, 
            "host": "10.255.138.13", 
            "lines": null, 
            "match": "line", 
            "parents": null, 
            "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "port": null, 
            "provider": {
                "host": "10.255.138.13", 
                "password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
                "transport": "cli", 
                "username": "admin"
            }, 
            "replace": "line", 
            "save": false, 
            "src": "router eigrp 200\n\ninterface Ethernet1/48\n 
 description testing2\n  no switchport \n  ip address 1.1.1.1/24\n\nrouter 
bgp 65000\n\n", 
            "ssh_keyfile": null, 
            "timeout": 10, 
            "transport": "cli", 
            "use_ssl": false, 
            "username": "admin", 
            "validate_certs": true
        }
    }, 
    "warnings": []
}


TASK [Display the result of the task] 
***********************************************************
task path: /home/admin/Ansible/testing/nxos_config.yml:41
ok: [10.255.138.13] => {
    "result2": {
        "changed": true, 
        "warnings": []
    }
}


PLAY RECAP 
**************************************************************************************
10.255.138.13              : ok=3    changed=1    unreachable=0    failed=0 
  


-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/954453ac-29ee-4279-9e10-1c866850d915%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to