ansible-collections / junipernetworks.junos

Ansible Network Collection for Juniper JunOS
GNU General Public License v3.0
82 stars 63 forks source link

junos_config: diff module output not displayed correctly ( Human readable) ; msg': \"Param 'provider' is deprecated #64

Closed gefela closed 4 years ago

gefela commented 4 years ago
SUMMARY

junos_config: junos playbook not displaying diff output correctly and msg': \"Param 'provider' is deprecated is displayed

ISSUE TYPE
COMPONENT NAME

junipernetworks.junos.junos_config

ANSIBLE VERSION
ansible 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
CONFIGURATION
ACTION_WARNINGS(default) = True
AGNOSTIC_BECOME_PROMPT(default) = True
ALLOW_WORLD_READABLE_TMPFILES(default) = False
ANSIBLE_CONNECTION_PATH(default) = None
ANSIBLE_COW_PATH(default) = None
ANSIBLE_COW_SELECTION(default) = default
ANSIBLE_COW_WHITELIST(default) = ['bud-frogs', 'bunny', 'cheese', 'daemon', 'default', 'dragon', 'elephant-in-snake',>
ANSIBLE_FORCE_COLOR(default) = False
ANSIBLE_NOCOLOR(default) = False
ANSIBLE_NOCOWS(default) = False
ANSIBLE_PIPELINING(default) = False
ANSIBLE_SSH_ARGS(default) = -C -o ControlMaster=auto -o ControlPersist=60s
ANSIBLE_SSH_CONTROL_PATH(default) = None
ANSIBLE_SSH_CONTROL_PATH_DIR(default) = ~/.ansible/cp
ANSIBLE_SSH_EXECUTABLE(default) = ssh
ANSIBLE_SSH_RETRIES(default) = 0
ANY_ERRORS_FATAL(default) = False
BECOME_ALLOW_SAME_USER(default) = False
BECOME_PLUGIN_PATH(default) = ['/root/.ansible/plugins/become', '/usr/share/ansible/plugins/become']
CACHE_PLUGIN(default) = memory
CACHE_PLUGIN_CONNECTION(default) = None
CACHE_PLUGIN_PREFIX(default) = ansible_facts
CACHE_PLUGIN_TIMEOUT(default) = 86400
COLLECTIONS_PATHS(default) = ['/root/.ansible/collections', '/usr/share/ansible/collections']
COLOR_CHANGED(default) = yellow
COLOR_CONSOLE_PROMPT(default) = white
COLOR_DEBUG(default) = dark gray
COLOR_DEPRECATE(default) = purple
COLOR_DIFF_ADD(default) = green
COLOR_DIFF_LINES(default) = cyan
COLOR_DIFF_REMOVE(default) = red
COLOR_ERROR(default) = red
COLOR_HIGHLIGHT(default) = white
COLOR_OK(default) = green
COLOR_SKIP(default) = cyan
COLOR_UNREACHABLE(default) = bright red
COLOR_VERBOSE(default) = blue
COLOR_WARN(default) = bright purple
COMMAND_WARNINGS(default) = True
CONDITIONAL_BARE_VARS(default) = True
CONNECTION_FACTS_MODULES(default) = {'eos': 'eos_facts', 'frr': 'frr_facts', 'ios': 'ios_facts', 'iosxr': 'iosxr_fact>
COVERAGE_REMOTE_OUTPUT(default) = None
COVERAGE_REMOTE_WHITELIST(default) = *
DEFAULT_ACTION_PLUGIN_PATH(default) = ['/root/.ansible/plugins/action', '/usr/share/ansible/plugins/action']
DEFAULT_ALLOW_UNSAFE_LOOKUPS(default) = False
DEFAULT_ASK_PASS(default) = False
DEFAULT_ASK_VAULT_PASS(default) = False
DEFAULT_BECOME(default) = False
DEFAULT_BECOME_ASK_PASS(default) = False
DEFAULT_BECOME_EXE(default) = None
DEFAULT_BECOME_FLAGS(default) = 
DEFAULT_BECOME_METHOD(default) = sudo
DEFAULT_BECOME_USER(default) = root
DEFAULT_CACHE_PLUGIN_PATH(default) = ['/root/.ansible/plugins/cache', '/usr/share/ansible/plugins/cache']
DEFAULT_CALLABLE_WHITELIST(default) = []
DEFAULT_CALLBACK_PLUGIN_PATH(default) = ['/root/.ansible/plugins/callback', '/usr/share/ansible/plugins/callback']
DEFAULT_CALLBACK_WHITELIST(default) = []
DEFAULT_CLICONF_PLUGIN_PATH(default) = ['/root/.ansible/plugins/cliconf', '/usr/share/ansible/plugins/cliconf']
DEFAULT_CONNECTION_PLUGIN_PATH(default) = ['/root/.ansible/plugins/connection', '/usr/share/ansible/plugins/connectio>
DEFAULT_DEBUG(default) = False
DEFAULT_EXECUTABLE(default) = /bin/sh
DEFAULT_FACT_PATH(default) = None
DEFAULT_FILTER_PLUGIN_PATH(default) = ['/root/.ansible/plugins/filter', '/usr/share/ansible/plugins/filter']
DEFAULT_FORCE_HANDLERS(default) = False
DEFAULT_FORKS(default) = 5
DEFAULT_GATHERING(default) = implicit
DEFAULT_GATHER_SUBSET(default) = ['all']
DEFAULT_GATHER_TIMEOUT(default) = 10
DEFAULT_HANDLER_INCLUDES_STATIC(default) = False
DEFAULT_HASH_BEHAVIOUR(default) = replace
DEFAULT_HOST_LIST(default) = ['/etc/ansible/hosts']
DEFAULT_HTTPAPI_PLUGIN_PATH(default) = ['/root/.ansible/plugins/httpapi', '/usr/share/ansible/plugins/httpapi']
DEFAULT_INTERNAL_POLL_INTERVAL(default) = 0.001
DEFAULT_INVENTORY_PLUGIN_PATH(default) = ['/root/.ansible/plugins/inventory', '/usr/share/ansible/plugins/inventory']
DEFAULT_JINJA2_EXTENSIONS(default) = []
DEFAULT_JINJA2_NATIVE(default) = False
DEFAULT_KEEP_REMOTE_FILES(default) = False
DEFAULT_LIBVIRT_LXC_NOSECLABEL(default) = False
DEFAULT_LOAD_CALLBACK_PLUGINS(default) = False
DEFAULT_LOCAL_TMP(default) = /root/.ansible/tmp/ansible-local-981k6lh2qkt
DEFAULT_LOG_FILTER(default) = []
DEFAULT_LOG_PATH(default) = None
DEFAULT_LOOKUP_PLUGIN_PATH(default) = ['/root/.ansible/plugins/lookup', '/usr/share/ansible/plugins/lookup']
DEFAULT_MANAGED_STR(default) = Ansible managed
DEFAULT_MODULE_ARGS(default) = 
DEFAULT_MODULE_COMPRESSION(default) = ZIP_DEFLATED
DEFAULT_MODULE_NAME(default) = command
DEFAULT_MODULE_PATH(default) = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
DEFAULT_MODULE_UTILS_PATH(default) = ['/root/.ansible/plugins/module_utils', '/usr/share/ansible/plugins/module_utils>
DEFAULT_NETCONF_PLUGIN_PATH(default) = ['/root/.ansible/plugins/netconf', '/usr/share/ansible/plugins/netconf']
DEFAULT_NO_LOG(default) = False
DEFAULT_NO_TARGET_SYSLOG(default) = False
DEFAULT_NULL_REPRESENTATION(default) = None
DEFAULT_POLL_INTERVAL(default) = 15
DEFAULT_PRIVATE_KEY_FILE(default) = None
DEFAULT_PRIVATE_ROLE_VARS(default) = False
DEFAULT_REMOTE_PORT(default) = None
DEFAULT_REMOTE_USER(default) = None
DEFAULT_ROLES_PATH(default) = ['/root/.ansible/roles', '/usr/share/ansible/roles', '/etc/ansible/roles']
DEFAULT_SCP_IF_SSH(default) = smart
DEFAULT_SELINUX_SPECIAL_FS(default) = ['fuse', 'nfs', 'vboxsf', 'ramfs', '9p', 'vfat']
DEFAULT_SFTP_BATCH_MODE(default) = True
DEFAULT_SQUASH_ACTIONS(default) = ['apk', 'apt', 'dnf', 'homebrew', 'openbsd_pkg', 'pacman', 'pip', 'pkgng', 'yum', '>
DEFAULT_SSH_TRANSFER_METHOD(default) = None
DEFAULT_STDOUT_CALLBACK(default) = default
DEFAULT_STRATEGY(default) = linear
DEFAULT_STRATEGY_PLUGIN_PATH(default) = ['/root/.ansible/plugins/strategy', '/usr/share/ansible/plugins/strategy']
DEFAULT_SU(default) = False
DEFAULT_SYSLOG_FACILITY(default) = LOG_USER
DEFAULT_TASK_INCLUDES_STATIC(default) = False
DEFAULT_TERMINAL_PLUGIN_PATH(default) = ['/root/.ansible/plugins/terminal', '/usr/share/ansible/plugins/terminal']
DEFAULT_TEST_PLUGIN_PATH(default) = ['/root/.ansible/plugins/test', '/usr/share/ansible/plugins/test']
DEFAULT_TIMEOUT(default) = 10
DEFAULT_TRANSPORT(default) = smart
DEFAULT_UNDEFINED_VAR_BEHAVIOR(default) = True
DEFAULT_VARS_PLUGIN_PATH(default) = ['/root/.ansible/plugins/vars', '/usr/share/ansible/plugins/vars']
DEFAULT_VAULT_ENCRYPT_IDENTITY(default) = None
DEFAULT_VAULT_IDENTITY(default) = default
DEFAULT_VAULT_IDENTITY_LIST(default) = []
DEFAULT_VAULT_ID_MATCH(default) = False
DEFAULT_VAULT_PASSWORD_FILE(default) = None
DEFAULT_VERBOSITY(default) = 0
DEPRECATION_WARNINGS(default) = True
DIFF_ALWAYS(default) = False
DIFF_CONTEXT(default) = 3
DISPLAY_ARGS_TO_STDOUT(default) = False
DISPLAY_SKIPPED_HOSTS(default) = True
DOCSITE_ROOT_URL(default) = https://docs.ansible.com/ansible/
DOC_FRAGMENT_PLUGIN_PATH(default) = ['/root/.ansible/plugins/doc_fragments', '/usr/share/ansible/plugins/doc_fragment>
DUPLICATE_YAML_DICT_KEY(default) = warn
ENABLE_TASK_DEBUGGER(default) = False
ERROR_ON_MISSING_HANDLER(default) = True
FACTS_MODULES(default) = ['smart']
GALAXY_IGNORE_CERTS(default) = False
GALAXY_ROLE_SKELETON(default) = None
GALAXY_ROLE_SKELETON_IGNORE(default) = ['^.git$', '^.*/.git_keep$']
GALAXY_SERVER(default) = https://galaxy.ansible.com
GALAXY_SERVER_LIST(default) = None
GALAXY_TOKEN(default) = None
GALAXY_TOKEN_PATH(default) = /root/.ansible/galaxy_token
HOST_KEY_CHECKING(env: ANSIBLE_HOST_KEY_CHECKING) = False
HOST_PATTERN_MISMATCH(default) = warning
INJECT_FACTS_AS_VARS(default) = True
INTERPRETER_PYTHON(default) = auto_legacy
INTERPRETER_PYTHON_DISTRO_MAP(default) = {'centos': {'6': '/usr/bin/python', '8': '/usr/libexec/platform-python'}, 'f>
INTERPRETER_PYTHON_FALLBACK(default) = ['/usr/bin/python', 'python3.7', 'python3.6', 'python3.5', 'python2.7', 'pytho>
INVALID_TASK_ATTRIBUTE_FAILED(default) = True
INVENTORY_ANY_UNPARSED_IS_FAILED(default) = False
INVENTORY_CACHE_ENABLED(default) = False
INVENTORY_CACHE_PLUGIN(default) = None
INVENTORY_CACHE_PLUGIN_CONNECTION(default) = None
INVENTORY_CACHE_PLUGIN_PREFIX(default) = ansible_facts
INVENTORY_CACHE_TIMEOUT(default) = 3600
INVENTORY_ENABLED(default) = ['host_list', 'script', 'auto', 'yaml', 'ini', 'toml']
INVENTORY_EXPORT(default) = False
INVENTORY_IGNORE_EXTS(default) = {{(BLACKLIST_EXTS + ( '.orig', '.ini', '.cfg', '.retry'))}}
INVENTORY_IGNORE_PATTERNS(default) = []
INVENTORY_UNPARSED_IS_FAILED(default) = False
LOCALHOST_WARNING(default) = True
MAX_FILE_SIZE_FOR_DIFF(default) = 104448
NETCONF_SSH_CONFIG(default) = None
NETWORK_GROUP_MODULES(default) = ['eos', 'nxos', 'ios', 'iosxr', 'junos', 'enos', 'ce', 'vyos', 'sros', 'dellos9', 'd>
OLD_PLUGIN_CACHE_CLEARING(default) = False
PARAMIKO_HOST_KEY_AUTO_ADD(default) = False
PARAMIKO_LOOK_FOR_KEYS(default) = True
PERSISTENT_COMMAND_TIMEOUT(default) = 30
PERSISTENT_CONNECT_RETRY_TIMEOUT(default) = 15
PERSISTENT_CONNECT_TIMEOUT(default) = 30
PERSISTENT_CONTROL_PATH_DIR(default) = /root/.ansible/pc
PLAYBOOK_DIR(default) = None
PLAYBOOK_VARS_ROOT(default) = top
PLUGIN_FILTERS_CFG(default) = None
PYTHON_MODULE_RLIMIT_NOFILE(default) = 0
RETRY_FILES_ENABLED(default) = False
RETRY_FILES_SAVE_PATH(default) = None
SHOW_CUSTOM_STATS(default) = False
STRING_CONVERSION_ACTION(default) = warn
STRING_TYPE_FILTERS(default) = ['string', 'to_json', 'to_nice_json', 'to_yaml', 'ppretty', 'json']
SYSTEM_WARNINGS(default) = True
TAGS_RUN(default) = []
TAGS_SKIP(default) = []
TASK_DEBUGGER_IGNORE_ERRORS(default) = True
TRANSFORM_INVALID_GROUP_CHARS(default) = never
USE_PERSISTENT_CONNECTIONS(default) = False
VARIABLE_PRECEDENCE(default) = ['all_inventory', 'groups_inventory', 'all_plugins_inventory', 'all_plugins_play', 'gr>
VERBOSE_TO_STDERR(default) = False
YAML_FILENAME_EXTENSIONS(default) = ['.yml', '.yaml', '.json']
OS / ENVIRONMENT

OS = Redhat v 8.1

Target OS = 
Hostname: dmz-firewall
Model: vSRX
Junos: 19.2R1-S2.2
JUNOS OS Kernel 64-bit XEN [20191120.0ebd4bf_builder_stable_11]
JUNOS OS libs [20191120.0ebd4bf_builder_stable_11]
JUNOS OS runtime [20191120.0ebd4bf_builder_stable_11]
JUNOS OS time zone information [20191120.0ebd4bf_builder_stable_11]
JUNOS OS libs compat32 [20191120.0ebd4bf_builder_stable_11]
JUNOS OS 32-bit compatibility [20191120.0ebd4bf_builder_stable_11]
JUNOS py extensions [20191121.175308_builder_junos_192_r1_s2]
JUNOS py base [20191121.175308_builder_junos_192_r1_s2]
JUNOS OS vmguest [20191120.0ebd4bf_builder_stable_11]
JUNOS OS support utilities [20191120.0ebd4bf_builder_stable_11]
JUNOS OS crypto [20191120.0ebd4bf_builder_stable_11]
JUNOS network stack and utilities [20191121.175308_builder_junos_192_r1_s2]
JUNOS libs [20191121.175308_builder_junos_192_r1_s2]
JUNOS libs compat32 [20191121.175308_builder_junos_192_r1_s2]
JUNOS runtime [20191121.175308_builder_junos_192_r1_s2]
JUNOS na telemetry [19.2R1-S2.2]
JUNOS Web Management Platform Package [20191121.175308_builder_junos_192_r1_s2]
JUNOS vsrx modules [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx libs compat32 [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx runtime [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx platform support [20191121.175308_builder_junos_192_r1_s2]
JUNOS common platform support [20191121.175308_builder_junos_192_r1_s2]
JUNOS vsrx runtime [20191121.175308_builder_junos_192_r1_s2]
JUNOS pppoe [20191121.175308_builder_junos_192_r1_s2]
JUNOS Openconfig [19.2R1-S2.2]
JUNOS mtx network modules [20191121.175308_builder_junos_192_r1_s2]
JUNOS modules [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx libs [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx Data Plane Crypto Support [20191121.175308_builder_junos_192_r1_s2]
JUNOS daemons [20191121.175308_builder_junos_192_r1_s2]
JUNOS srx daemons [20191121.175308_builder_junos_192_r1_s2]
JUNOS SRX TVP AppQos Daemon [20191121.175308_builder_junos_192_r1_s2]
JUNOS Extension Toolkit [20191121.175308_builder_junos_192_r1_s2]
JUNOS Juniper Malware Removal Tool (JMRT) [1.0.0+20191121.175308_builder_junos_192_r1_s2]
JUNOS J-Insight [20191121.175308_builder_junos_192_r1_s2]
JUNOS Online Documentation [20191121.175308_builder_junos_192_r1_s2]
JUNOS jail runtime [20191120.0ebd4bf_builder_stable_11]
JUNOS FIPS mode utilities [20191121.175308_builder_junos_192_r1_s2]
STEPS TO REPRODUCE
[juniper]
172.16.203.121

[juniper:vars]
ansible_user=****************
ansible_network_os=junipernetworks.junos.junos
ansible_connection=local
ansible_password=***************

- name: Juniper SRX configuration compliance checks 
  hosts: juniper
  gather_facts: false
  tasks:
  - set_fact:
         config_directory: '{{ "/home/gefelas/ansible_junos/files/" }}'
  - name: Syslog server check
    junipernetworks.junos.junos_config:
      src: '{{ config_directory }}/syslog_config.txt'
      src_format: set
      comment: Ensure that appropriate Syslog server configured 
    register: junos_output
    diff: true
  - debug:
       var: junos_output

  - name: success
    debug:
      msg: Syslog server check - This check has passed with the following output({{ junos_output }})
    when: not junos_output.changed 

  - name: failed
    debug:
      msg: Syslog server check - This check has failed with the following output({{ junos_output }})
    when: junos_output.changed 

  - name: Admin credentials check
    junipernetworks.junos.junos_config:
      src: '{{ config_directory }}/admin_user.txt'
      comment: Ensure that Admin user havee been created
    register: junos_output
    diff: true
  - debug:
       var: junos_output

  - name: success
    debug:
      msg: Admin credentials check - This check has passed with the following output({{ junos_output }})
    when: not junos_output.changed 

  - name: failed
    debug:
      msg: Admin credentials check - This check has failed with the following output({{ junos_output }})
    when: junos_output.changed 

  - name: NTP Server check 
    junipernetworks.junos.junos_config:
      src: '{{ config_directory }}/NTP_server.txt'
      comment: Ensure that correct NTP servers has been configured
    register: junos_output
    diff: true
  - debug:
       var: junos_output

  - name: success
    debug:
      msg: NTP Server check  - This check has passed with the following output({{ junos_output }})
    when: not junos_output.changed 

  - name: failed
    debug:
      msg: NTP Server check  - This check has failed with the following output({{ junos_output }})
    when: junos_output.changed 

  - name: Idle timeout check 
    junipernetworks.junos.junos_config:
      src: '{{ config_directory }}/idle_timeout.txt'
      comment: Ensure that idle timeout has been configured
    register: junos_output
    diff: true
  - debug:
       var: junos_output

  - name: success
    debug:
      msg: Idle timeout check   - This check has passed with the following output({{ junos_output }})
    when: not junos_output.changed 

  - name: failed
    debug:
      msg: Idle timeout check   - This check has failed with the following output({{ junos_output }})
    when: junos_output.changed 
EXPECTED RESULTS

The results should be as a result of comparing the src directory against the configuration of juniper vsrx ... The src files are similar to these https://github.com/gefela/ansible_junos/tree/master/files However the output is not displayed correctly

ACTUAL RESULTS

When I run this command .

ansible-playbook -i inventory junos_config_new.yml --check -vvv

I get the following error message .

sudo ansible-playbook -i inventory junos_config_new.yml  --check -vvv
[sudo] password for gefelas: 
ansible-playbook 2.9.9
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /bin/ansible-playbook
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /home/gefelas/ansible_junos/inventory as it did not pass its verify_file() method
script declined parsing /home/gefelas/ansible_junos/inventory as it did not pass its verify_file() method
auto declined parsing /home/gefelas/ansible_junos/inventory as it did not pass its verify_file() method
Parsed /home/gefelas/ansible_junos/inventory inventory source with ini plugin

PLAYBOOK: junos_config_new.yml *****************************************************************************************************************************
1 plays in junos_config_new.yml

PLAY [Juniper SRX configuration compliance checks] *********************************************************************************************************
META: ran handlers

TASK [set_fact] ********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:6
ok: [172.16.203.121] => {
    "ansible_facts": {
        "config_directory": "/home/gefelas/ansible_junos/files/"
    },
    "changed": false
}

TASK [Syslog server check] *********************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:8
<172.16.203.121> using connection plugin netconf (was local)
<172.16.203.121> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.16.203.121> EXEC /bin/sh -c 'echo ~root && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948 && echo ansible-tmp-1592490545.731142-52320-201879998426948="` echo /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948 `" ) && sleep 0'
<172.16.203.121> Attempting python interpreter discovery
<172.16.203.121> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '/bin/python3.6 && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
<172.16.203.121> PUT /root/.ansible/tmp/ansible-local-52311nkl6r8cg/tmpreqda8m6 TO /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948/AnsiballZ_junos_config.py
<172.16.203.121> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948/ /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1592490545.731142-52320-201879998426948/ > /dev/null 2>&1 && sleep 0'
[edit system syslog host 192.168.100.70]
+     interactive-commands any;
[edit system syslog host 192.168.100.70]
+    facility-override local1;
+    log-prefix firewall;
+    source-address 172.16.203.121;
+    explicit-priority;
[edit system syslog]
+    file messages {
+        any critical;
+        authorization info;
+    }
+    file default-log-messages {
+        structured-data;
+    }
+    file sessions {
+        user info;
+    }
+    file interactive-commands {
+        interactive-commands error;
+    }
[DEPRECATION WARNING]: Param 'provider' is deprecated. See the module docs for more information. This feature will be removed in version 2.14. Deprecation 
warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
changed: [172.16.203.121] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": true,
    "diff": {
        "prepared": "[edit system syslog host 192.168.100.70]\n+     interactive-commands any;\n[edit system syslog host 192.168.100.70]\n+    facility-override local1;\n+    log-prefix firewall;\n+    source-address 172.16.203.121;\n+    explicit-priority;\n[edit system syslog]\n+    file messages {\n+        any critical;\n+        authorization info;\n+    }\n+    file default-log-messages {\n+        structured-data;\n+    }\n+    file sessions {\n+        user info;\n+    }\n+    file interactive-commands {\n+        interactive-commands error;\n+    }"
    },
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "check_commit": false,
            "comment": "Ensure that appropriate Syslog server configured",
            "confirm": 0,
            "confirm_commit": false,
            "lines": null,
            "provider": {
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": null
            },
            "replace": null,
            "rollback": null,
            "src": "set system syslog archive size 300000\nset system syslog archive files 3\nset system syslog archive world-readable\nset system syslog user * any emergency\nset system syslog host 192.168.100.70 any any\nset system syslog host 192.168.100.70 interactive-commands any\nset system syslog host 192.168.100.70 facility-override local1\nset system syslog host 192.168.100.70 log-prefix firewall\nset system syslog host 192.168.100.70 source-address \"172.16.203.121\"\nset system syslog host 192.168.100.70 explicit-priority\nset system syslog file messages any critical\nset system syslog file messages authorization info\nset system syslog file default-log-messages structured-data\nset system syslog file sessions user info\nset system syslog file interactive-commands interactive-commands error\n",
            "src_format": "set",
            "update": "merge",
            "zeroize": false
        }
    }
}

TASK [debug] ***********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:15
ok: [172.16.203.121] => {
    "junos_output": {
        "ansible_facts": {
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": true,
        "deprecations": [
            {
                "msg": "Param 'provider' is deprecated. See the module docs for more information",
                "version": 2.14
            }
        ],
        "diff": {
            "prepared": "[edit system syslog host 192.168.100.70]\n+     interactive-commands any;\n[edit system syslog host 192.168.100.70]\n+    facility-override local1;\n+    log-prefix firewall;\n+    source-address 172.16.203.121;\n+    explicit-priority;\n[edit system syslog]\n+    file messages {\n+        any critical;\n+        authorization info;\n+    }\n+    file default-log-messages {\n+        structured-data;\n+    }\n+    file sessions {\n+        user info;\n+    }\n+    file interactive-commands {\n+        interactive-commands error;\n+    }"
        },
        "failed": false
    }
}

TASK [success] *********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:18
skipping: [172.16.203.121] => {}

TASK [failed] **********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:23
ok: [172.16.203.121] => {
    "msg": "Syslog server check - This check has failed with the following output({'changed': True, 'diff': {'prepared': '[edit system syslog host 192.168.100.70]\\n+     interactive-commands any;\\n[edit system syslog host 192.168.100.70]\\n+    facility-override local1;\\n+    log-prefix firewall;\\n+    source-address 172.16.203.121;\\n+    explicit-priority;\\n[edit system syslog]\\n+    file messages {\\n+        any critical;\\n+        authorization info;\\n+    }\\n+    file default-log-messages {\\n+        structured-data;\\n+    }\\n+    file sessions {\\n+        user info;\\n+    }\\n+    file interactive-commands {\\n+        interactive-commands error;\\n+    }'}, 'deprecations': [{'msg': \"Param 'provider' is deprecated. See the module docs for more information\", 'version': 2.14}], 'ansible_facts': {'discovered_interpreter_python': '/usr/libexec/platform-python'}, 'failed': False})"
}

TASK [Admin credentials check] *****************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:29
<172.16.203.121> using connection plugin netconf (was local)
<172.16.203.121> identified ncclient device handler: junos.
<172.16.203.121> ESTABLISH NETCONF SSH CONNECTION FOR USER: root on PORT 830 TO 172.16.203.121 WITH SSH_CONFIG = None
<172.16.203.121> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.16.203.121> EXEC /bin/sh -c 'echo ~root && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432 && echo ansible-tmp-1592490550.3698227-52363-198623359777432="` echo /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
<172.16.203.121> PUT /root/.ansible/tmp/ansible-local-52311nkl6r8cg/tmprdv_25dz TO /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432/AnsiballZ_junos_config.py
<172.16.203.121> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432/ /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1592490550.3698227-52363-198623359777432/ > /dev/null 2>&1 && sleep 0'
ok: [172.16.203.121] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "check_commit": false,
            "comment": "Ensure that Admin user havee been created",
            "confirm": 0,
            "confirm_commit": false,
            "lines": null,
            "provider": {
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": null
            },
            "replace": null,
            "rollback": null,
            "src": "set system login user admin uid 101\nset system login user admin class super-user\nset system login user admin authentication encrypted-password $1$mysecret$AAg03pXKlOZeFEr//KrxT.\n",
            "src_format": null,
            "update": "merge",
            "zeroize": false
        }
    }
}

TASK [debug] ***********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:35
ok: [172.16.203.121] => {
    "junos_output": {
        "changed": false,
        "deprecations": [
            {
                "msg": "Param 'provider' is deprecated. See the module docs for more information",
                "version": 2.14
            }
        ],
        "failed": false
    }
}

TASK [success] *********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:38
ok: [172.16.203.121] => {
    "msg": "Admin credentials check - This check has passed with the following output({'changed': False, 'deprecations': [{'msg': \"Param 'provider' is deprecated. See the module docs for more information\", 'version': 2.14}], 'failed': False})"
}

TASK [failed] **********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:43
skipping: [172.16.203.121] => {}

TASK [NTP Server check] ************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:49
<172.16.203.121> using connection plugin netconf (was local)
<172.16.203.121> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.16.203.121> EXEC /bin/sh -c 'echo ~root && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396 && echo ansible-tmp-1592490553.474145-52396-186605027168396="` echo /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
<172.16.203.121> PUT /root/.ansible/tmp/ansible-local-52311nkl6r8cg/tmp3q_9lh0r TO /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396/AnsiballZ_junos_config.py
<172.16.203.121> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396/ /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1592490553.474145-52396-186605027168396/ > /dev/null 2>&1 && sleep 0'
ok: [172.16.203.121] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "check_commit": false,
            "comment": "Ensure that correct NTP servers has been configured",
            "confirm": 0,
            "confirm_commit": false,
            "lines": null,
            "provider": {
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": null
            },
            "replace": null,
            "rollback": null,
            "src": "set system ntp server 1.1.1.1 key 12                   \nset system ntp server 1.1.1.2\nset system ntp server 1.1.1.3 key 16\nset system ntp server 1.1.1.4 key 15\nset system ntp server 1.1.1.3 prefer\n",
            "src_format": null,
            "update": "merge",
            "zeroize": false
        }
    }
}

TASK [debug] ***********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:55
ok: [172.16.203.121] => {
    "junos_output": {
        "changed": false,
        "deprecations": [
            {
                "msg": "Param 'provider' is deprecated. See the module docs for more information",
                "version": 2.14
            }
        ],
        "failed": false
    }
}

TASK [success] *********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:58
ok: [172.16.203.121] => {
    "msg": "NTP Server check  - This check has passed with the following output({'changed': False, 'deprecations': [{'msg': \"Param 'provider' is deprecated. See the module docs for more information\", 'version': 2.14}], 'failed': False})"
}

TASK [failed] **********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:63
skipping: [172.16.203.121] => {}

TASK [Idle timeout check] **********************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:69
<172.16.203.121> using connection plugin netconf (was local)
<172.16.203.121> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.16.203.121> EXEC /bin/sh -c 'echo ~root && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /root/.ansible/tmp `"&& mkdir /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168 && echo ansible-tmp-1592490556.5086114-52427-253553669053168="` echo /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168 `" ) && sleep 0'
Using module file /root/.ansible/collections/ansible_collections/junipernetworks/junos/plugins/modules/junos_config.py
<172.16.203.121> PUT /root/.ansible/tmp/ansible-local-52311nkl6r8cg/tmpqjpcrunk TO /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168/AnsiballZ_junos_config.py
<172.16.203.121> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168/ /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c '/usr/libexec/platform-python /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168/AnsiballZ_junos_config.py && sleep 0'
<172.16.203.121> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1592490556.5086114-52427-253553669053168/ > /dev/null 2>&1 && sleep 0'
ok: [172.16.203.121] => {
    "changed": false,
    "invocation": {
        "module_args": {
            "backup": false,
            "backup_options": null,
            "check_commit": false,
            "comment": "Ensure that idle timeout has been configured",
            "confirm": 0,
            "confirm_commit": false,
            "lines": null,
            "provider": {
                "host": null,
                "password": null,
                "port": null,
                "ssh_keyfile": null,
                "timeout": null,
                "transport": "netconf",
                "username": null
            },
            "replace": null,
            "rollback": null,
            "src": "set system login class super-user-local idle-timeout 10\n",
            "src_format": null,
            "update": "merge",
            "zeroize": false
        }
    }
}

TASK [debug] ***********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:75
ok: [172.16.203.121] => {
    "junos_output": {
        "changed": false,
        "deprecations": [
            {
                "msg": "Param 'provider' is deprecated. See the module docs for more information",
                "version": 2.14
            }
        ],
        "failed": false
    }
}

TASK [success] *********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:78
ok: [172.16.203.121] => {
    "msg": "Idle timeout check   - This check has passed with the following output({'changed': False, 'deprecations': [{'msg': \"Param 'provider' is deprecated. See the module docs for more information\", 'version': 2.14}], 'failed': False})"
}

TASK [failed] **********************************************************************************************************************************************
task path: /home/gefelas/ansible_junos/junos_config_new.yml:83
skipping: [172.16.203.121] => {}
META: ran handlers
META: ran handlers

PLAY RECAP *************************************************************************************************************************************************
172.16.203.121             : ok=13   changed=1    unreachable=0    failed=0    skipped=4    rescued=0    ignored=0   

What do I have to do to displayed the output in a human readable format How do I get it to remove the extra spaces ( \n \n+ ) and text and get it to look like this ( human readable) below ?

set system syslog host 192.168.100.70 interactive-commands any set system syslog host 192.168.100.70 facility-override local1 set system syslog host 192.168.100.70 log-prefix firewall set system syslog host 192.168.100.70 source-address 172.16.203.121 set system syslog host 192.168.100.70 explicit-priority set system syslog file messages any critical set system syslog file messages authorization info

I have tried using these examples in the past

https://serverfault.com/questions/640130/display-output-with-ansible https://stackoverflow.com/questions/34188167/ansible-print-message-debug-msg-line1-n-var2-n-line3-with-var3

gefela commented 4 years ago

I have updated the playbook to look like this


When I run this , it is failing at this

TASK [debug] *** task path: /home/gefelas/ansible_junos/junos_config_new.yml:30 fatal: [172.16.203.121]: FAILED! => msg: |- The task includes an option with an undefined variable. The error was: 'dict object' has no attribute 'diff'

The error appears to be in '/home/gefelas/ansible_junos/junos_config_new.yml': line 30, column 5, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

    register: junos_output1
  - debug:
    ^ here

PLAY RECAP ***** 172.16.203.121 : ok=5 changed=1 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0

https://pastebin.com/QXtFvBdQ

rohitthakur2590 commented 4 years ago

@gefela what I could see here is when you are having an output for msg: Syslog server check - This check has failed with the following output({{ junos_output.diff.prepared }}), looks like junos_output doesn't have a key called diff. You could have only junos_output to see the whole output.

you could also refer to https://docs.ansible.com/ansible/latest/plugins/callback.html to know more about callback plugins to customize how the output is rendered.

gefela commented 4 years ago

I have used this in my ansible.cfg stdout_callback = community.general.yaml and changed my playbook to this


I have used junos.output instead but it is not display the output at all

TASK [debug] *** task path: /home/gefelas/ansible_junos/junos_config_new.yml:30 ok: [172.16.203.121] => msg: 'Admin credentials check - This check has passed with the following output({''changed'': False, ''deprecations'': [{''msg'': "Param ''provider'' is deprecated. See the module docs for more information", ''version'': 2.14}], ''failed'': False})'

TASK [debug] *** task path: /home/gefelas/ansible_junos/junos_config_new.yml:33 skipping: [172.16.203.121] =>

https://pastebin.com/91xAeUNi

rohitthakur2590 commented 4 years ago

@gefela In the task where it's not showing output and displaying skipping [172.16.203.121] =>, is because of your condition (when) hasn't met and that's why it is skipping. Your condition needs to be based on the output you are getting/expecting.

gefela commented 4 years ago

The problem is that when the condition is met , the reason why the sucess or failure is happening is not display exclude the first one

The first check display the following output

TASK [debug] *** task path: /home/gefelas/ansible_junos/junos_config_new.yml:20 ok: [172.16.203.121] => msg: |- Syslog server check - This check has failed with the following output([edit system syslog host 192.168.100.70]

The second one is

ok: [172.16.203.121] => msg: 'Admin credentials check - This check has passed with the following output({''changed'': False, ''deprecations'': [{''msg'': "Param ''provider'' is deprecated. See the module docs for more information", ''version'': 2.14}], ''failed'': False})'

The third one is

TASK [debug] *** task path: /home/gefelas/ansible_junos/junos_config_new.yml:48 ok: [172.16.203.121] => msg: 'NTP Server check - This check has failed with the following output({''changed'': False, ''deprecations'': [{''msg'': "Param ''provider'' is deprecated. See the module docs for more information", ''version'': 2.14}], ''failed'': False})'

rohitthakur2590 commented 4 years ago

@gefela it is the deprecation warning for connection local as connection local support has been deprecated for module could you try with netconf connection by changing ansible_connection=ansible.netcommon.netconf this should work fine and display the proper output.

rohitthakur2590 commented 4 years ago

Hi!

Thanks very much for your interest in Ansible. It sincerely means a lot to us.

This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.

IRC: #ansible on irc.freenode.net mailing list: https://groups.google.com/forum/#!forum/ansible-project If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.

Thank you once again and we look forward to seeing you on the list or IRC. Thanks!