Ansible configuration on remote Nodegrid devices
Ansible playbook can be used to automate remote devices. Every remote device needs to have one ansible user to apply the automation.
Follow this script to have complete configuration of ansible user, ssh keys, sudo permission on remote Nodegrid device.
Create these four files in one folder and later give them executable permission.
1. ansible_setup.sh
- #!/bin/sh
- read -p " Enter Your Choice 1(yes)/2(no): " choice
- while [ $choice -eq 1 ]
- do
- read -p "enter the ip address : " IPADDRESS
- echo " The ip address is $IPADDRESS "
- echo "Copy all config files to Nodegrid, provide root password"
- scp ansible_setup* root@$IPADDRESS:/tmp/
- echo "Create Ansible User and Group, provide root password"
- ssh root@$IPADDRESS 'su admin -l -c "cli -f /tmp/ansible_setup.cli"'
- echo "Create Ansible sudoers file, provide root password"
- ssh root@$IPADDRESS '/bin/bash /tmp/ansible_setup_sudoers.sh'
- echo "Copy ssh-key to Ansible user, provide ansible password"
- ssh-copy-id -i .ssh/id_rsa.pub ansible@$IPADDRESS
- echo "Applying the Sudo Permission"
- ssh root@$IPADDRESS 'su admin -l -c "cli -f /tmp/ansible_setup_sudop.cli"'
- echo "Delete setup files from Nodegrid, provide root password"
- ssh root@$IPADDRESS 'rm /tmp/ansible_setup*'
- read -p "Enter Your Choice 1(yes)/2(no): " choice
- done
2. ansible_setup.cli
- cd /settings/authorization/
- add
- set name=ansible
- commit
- cd ansible/profile/
- set track_system_information=yes
- set terminate_sessions=yes
- set software_upgrade_and_reboot_system=yes
- set configure_system=yes
- set configure_user_accounts=yes
- set apply_&_save_settings=yes
- set shell_access=yes
- set restrict_configure_system_permission_to_read_only=no
- set menu-driven_access_to_devices=no
- set custom_session_timeout=no
- set startup_application=shell
- commit
- cd /settings/local_accounts/
- add
- set username=ansible
- set password=1234
- set hash_format_password=no
- set user_group=ansible
- commit
3. ansible_setup_sudoers.sh
- #!/bin/bash
- echo "ansible ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/ansible
- chmod 600 /etc/sudoers.d/ansible
4. ansible_setup_sudop.cli
- set /settings/authorization/ansible/profile/ sudo_permission=yes
- commit
Now, run the script : sudo ./ansible_setup.sh
Enter root password for remote nodegrid when asked and ansible password is what one has given in ansible_setup.cli file
Related Articles
How to: Enable Remote Access
Remote access is one of the multiple ZPE Cloud features. It allows you to access your Nodegrid device and target devices from anywhere in the world, as long as you have an internet connection.. Here's how to enable Remote Access on your Nodegrid ...
How to Manually Add NetApp Storage Devices to NodeGrid via WebUI
Select Managed Devices :: Devices, click the Add button to add a device in the system. For the purpose of this example, provide the following information: On the Name field, enter the name of the NetApp device you want to add. Enter the IP ...
How to Manually Add Network Devices with SSH or Telnet Support to NodeGrid via WebUI
Select Managed Devices :: Devices, click the Add button to add a device in the system. For the purpose of this example, provide the following information: On the Name field, enter the name of the device you want to add (for example a critical Red ...
How to Manually Add Network Devices with SSH or Telnet Support to NodeGrid via CLI
Access your NodeGrid via telnet, ssh, or console, and log in as admin. Type the following commands to add Console device to NodeGrid: [admin@nodegrid /]# add /settings/devices/ [admin@nodegrid {devices}]# set name=<device_name> [admin@nodegrid ...
How to Manually Add NetApp Storage Devices to NodeGrid via CLI
Access your NodeGrid via telnet, ssh, or console, and log in as admin. Type the following commands to add a NetApp device to NodeGrid: [admin@nodegrid /]# add /settings/devices/ [admin@nodegrid {devices}]# set name=<netapp_server> [admin@nodegrid ...