--- title: "Ansible Examples" slug: "ansible-examples" updated: 2026-10-27T12:25:28Z published: 2026-10-27T12:25:28Z canonical: "docs.zpesystems.com/ansible-examples" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.zpesystems.com/llms.txt > Use this file to discover all available pages before exploring further. # Ansible Examples ## Ansible Collection Nodegrid OS-specific Ansible collection and examples are available to all customers on GitHub ([link](https://github.com/ZPESystems/Ansible/tree/main)). Customers can deploy the collection on an existing Nodegrid appliance, an [Ansible](https://www.ansible.com/) Controller, or [Ansible Automation Platform](https://www.ansible.com/products/automation-platform), or RedHats Opensource project [AWX](https://github.com/ansible/awx). ### Examples The collections come with multiple examples of how to use available Ansible Collections. These can be a starting point to develop other playbooks for other needs. If assistance is needed to develop playbooks, contact ZPE professional services department. A list of playbooks is provided in the table. | Category | Name | Description | | --- | --- | --- | | Managed Devices | md_create_device.yml | Creates/Updates a Managed Device | | Managed Devices | md_set_auto_discovery.yml | Creates/Updates Auto Discovery Scans | | Network | net_create_connections.yml | Creates/Updates a Network Connection | | Network | net_set_settings.yml | Updates General Network Settings, like hostname and failover settings | | General | ng_get_facts.yml | Retrievs Nodegrid device facts, like version, model, and more | | General | ng_import_settings.yml | Enables to import any list of import_settings | | General | ng_export_settings.yml | Exports Nodegrid settings in the export_settings format to a local file | | General | ng_cli_cmd.yml | Allows running any Nodegrid Cli command | | General | ng_sync_managed_device.yml | Synchronizes a list of Managed Devices between multiple Nodegrid Appliances | | General | ng_sync_settings.yml | Syncronises a list of System Settings between multiple Nodegrid Appliances | | Security | sec_authentication_add_servers.yml | Creates/Updates Authentication Server settings | | Security | sec_authentication_add_sso.yml | Creates/Updates SSO Server settings | | Security | sec_authentication_add_two_factor.yml | Creates/Updates Two Factor authentication settings | | Security | sec_authorization_add_group.yml | Creates/Updates local user group settings | | Security | sec_password_rules_set.yml | Updates local user password rule settings | | Setup | setup_authorize_user.yml | Authorizes the users | | Setup | setup_configure_factory_nodegrid.yml | Creates factory default settings | | System | sys_date_time_set_auto.yml | Creates/Updates Systems Date and Time settings | | System | sys_date_time_set_manual.yml | Creates/Updates Systems Date and Time settings | | System | sys_licenses_add.yml | Adds a Nodegrid license to a Nodegrid system | | System | sys_ntp_authentication_add.yml | Creates/Updates NTP authentication settings | | System | sys_ntp_server_set.yml | Creates/Updates NTP server settings | | System | sys_preferences_set.yml | Updates System Preferences, like session timeout and more | ## Changing Nodegrid User Password Using Ansible This section provides information on how to change the Nodegrid user password using Ansible: - Changing user password in Nodegrid 6.0.13 or earlier versions - Changing user password in Nodegrid 6.0.15 or later versions ### Changing user password in Nodegrid 6.0.13 or earlier versions To change user password in Nodegrid 6.0.13 or earlier versions, follow these steps. These Nodegrid versions use Ansible with version 2.9.18. ```plaintext - name: Change user password at localhost  hosts: 127.0.0.1  connection: local  vars:    username: 'admin'    raw_password: ''  tasks:    - name: Change password hash      user: name={{ username }} password={{ raw_password|password_hash('sha512') }} update_password=always ``` ### Changing user password in Nodegrid 6.0.15 or later versions To change user passwords in Nodegrid 6.0.15 or later versions, follow the steps provided in this section. These Nodegrid versions use Ansible with version 2.17.1. > [!NOTE] > Note > > The passlib library used for user password hashing is an optional dependency in newer Ansible versions such as 2.17.1. Hence, the Ansible filter password_hash() will fail with an error. Refer to the information in this section on how to change user password with alternate methods. The user passwords can be updated in one of the following ways: - **Option 1: Change the way password_hash is generated using the OpenSSL command instead.** Or - **Option 2:** Install the passlib. **Option 1: Upgrade playbook. Change the way how to generate the password_hash** ```shell - name: Change user password at localhost  hosts: 127.0.0.1  connection: local  vars:    username: 'admin'    raw_password: ''  tasks:    - name: Generate password hash      shell: openssl passwd -6 -salt xyz {{ raw_password }}      register: password_hash    - name: Change password      user: name={{ username }} password={{ password_hash.stdout }} update_password=always ``` **Option 2: You can use Ansible filter password_hash(‘sha512’) to generate the user password, however you need to install the passlib** Follow these steps: 1. Add the library to the Nodegrid. 2. Install the passlib manually with the ansible user: ```shell # install the passlib     admin@nodegrid /]# shell sudo su - ansible     ansible@nodegrid:~$ pip3 install passlib ``` 3. Change the user password. ## Configure Managed Devices Through Serial Port It is possible to execute commands on a managed device connected to Nodegrid via its serial console ports. The workflow is as follows: 1. Connects to a managed device configured in Nodegrid via its serial console. 2. Reads the device prompt patterns from managed devices types. 3. Performs auto-login using the device credentials stored in Nodegrid. 4. Sends each command in the provided list and waits for the device’s shell prompt. ### Examples #### Playbook to Test Against a Managed Device ```shell --- - name: Show cisco details  hosts: "nscp-support-45_25"  gather_facts: false  collections:    - zpe.nodegrid  tasks:    - name: Provision Cisco SG220 switch      zpe.nodegrid.managed_device_command:        managed_device_name: Cisco        command_prompt: '\r\n\S+[#>]'        pager_prompt: '--More--'        force: true        commands:          - show version          - show running-config          - exit          - exit      register: output      changed_when: false    - name: Display Result      debug:        msg: "{{ item.output.split('\n') }}"      with_items: "{{ output.results }}"      loop_control:        label: "{{ item.command }}" ```