In this tutorial, I will show you how to use Ansible to manage a cluster of RISC-V based ‘K1’ development boards. We will start with the basic concepts of Ansible and the role of the cluster, and then gradually go into how to set up a control host and configure cluster nodes.
Basic concepts
Ansible is an open source automation platform for configuration management, application deployment, and task automation. It uses an agentless architecture and communicates with the target machine through the SSH protocol. It is suitable for managing various environments from single computers to large-scale clusters.
A cluster is a unit composed of multiple computers that work together to provide higher availability, reliability, and scalability. In a cluster environment, tasks can be distributed across multiple nodes to improve processing power and redundant data backup.
Building a cluster
Step 1: Hardware Connection

- Connect Power: Each ‘K1’ board requires its own power supply. Make sure to use the appropriate power adapter to provide stable power to each board.
- Network Connection: Connect each ‘K1’ board to a network switch or router using an Ethernet cable. This will allow the boards to communicate with each other within the local area network and to be accessible from the control host.
- Check Network Configuration: Make sure each board is configured with the correct network settings, including IP address, subnet mask, default gateway and DNS servers. These can be set by the Linux system on the board.
Step 2: Prepare the control host
The control host is the computer that runs the Ansible software and manages other machines. On your control host, you need to do the following:
Install Ansible: Open your terminal and execute the following command to install Ansible:
sudo apt update
sudo apt install ansible
Install SSH password management tool: Ansible connects to cluster nodes via SSH. If you choose to use a password instead of a key, you need to install sshpass:
sudo apt-get install sshpass
Configure Ansible: Edit the Ansible configuration file /etc/ansible/ansible.cfg to enable SSH password authentication and make sure the following line is set to True:
[defaults]
ask_pass = True
Step 3: Configure the cluster
Configuration of the cluster involves setting up each ‘K1’ board so that they can be managed by the control host.
Set up network connectivity: Make sure all ‘K1’ boards have the Linux operating system installed and are connected to the network.
Create the Ansible inventory file: On the control host, create a file called hosts that specifies the IP addresses and SSH login credentials for all devices in the cluster:
[k1_cluster]
192.168.1.101 ansible_ssh_user=user ansible_ssh_pass=yourpassword
192.168.1.102 ansible_ssh_user=user ansible_ssh_pass=yourpassword
192.168.1.103 ansible_ssh_user=user ansible_ssh_pass=yourpassword
192.168.1.104 ansible_ssh_user=user ansible_ssh_pass=yourpassword
Verify connectivity: Test that Ansible can connect to all nodes via SSH:
ansible -i hosts k1_cluster -m ping
Step 4: Practical Example – File Synchronization
Let’s experience the functions of the cluster through a specific operation. Here is how to synchronize files to the entire cluster:
Write Ansible Playbook: Create a playbook sync_files.yml to synchronize files to all nodes:
- name: Synchronize files across K1 development board cluster
hosts: k1_cluster
become: yes
tasks:
- name: Synchronize a directory
synchronize:
src: /path/to/local/directory
dest: /path/to/remote/directory
delete: yes
recursive: yes
Execute Playbook: Run the playbook to synchronize the directories:
ansible-playbook -i hosts sync_files.yml
Conclusion
Through this example, you have learned how to use Ansible to build and manage a Linux cluster on the ‘K1’ development board. This configuration not only improves operational efficiency, but also facilitates the expansion and maintenance of your system. With Ansible, you can easily deploy applications, synchronize files, or perform any automated tasks across multiple devices.