Ansible Examples

Prev Next

Ansible Libraries

Nodegrid OS-specific Ansible libraries and examples are available to all customers on GitHub (link).

Customers can deploy the libraries on an existing Nodegrid appliance, an Ansible Controller, or Ansible Automation Platform, or RedHats Opensource project AWX.

Examples

The libraries come with multiple examples of how to use available Ansible Libraries. 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.

- name: Change user password at localhost
  hosts: 127.0.0.1
  connection: local
  vars:
    username: 'admin'
    raw_password: '<user_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

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

- name: Change user password at localhost
  hosts: 127.0.0.1
  connection: local
  vars:
    username: 'admin'
    raw_password: '<user_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:

    # install the passlib    
    admin@nodegrid /]# shell sudo su - ansible    
    ansible@nodegrid:~$ pip3 install passlib
  3. Change the user password.