Bootstrapping a storage cluster with Ansible
As a storage administrator, you can bootstrap a storage cluster using Ansible by using the cephadm_bootstrap and cephadm_registry_login modules in your Ansible playbook.
Before you begin
- An IP address for the first Ceph Monitor container, which is also the IP address for the first node in the storage cluster.
- Login access to
cp.icr.io/cp. - A minimum of 10 GB of free space for
/var/lib/containers/. - Installation of the
cephadm-ansiblepackage on the Ansible administration node. - Passwordless SSH is set up on all hosts in the storage cluster.
For the latest supported Red Hat Enterprise Linux versions, see Compatibility matrix.
Procedure
- Log in to the Ansible administration node.
- Navigate to the
/usr/share/cephadm-ansibledirectory on the Ansible administration node.For example,
[ansible@admin ~]$ cd /usr/share/cephadm-ansible
- Create the
hostsfile and add hosts, labels, and monitor IP address of the first host in the storage cluster.sudo vi INVENTORY_FILE HOST1 labels="['LABEL1', 'LABEL2']" HOST2 labels="['LABEL1', 'LABEL2']" HOST3 labels="['LABEL1']" [admin] ADMIN_HOST monitor_address=MONITOR_IP_ADDRESS labels="['ADMIN_LABEL', 'LABEL1', 'LABEL2']"For example,
[ansible@admin cephadm-ansible]$ sudo vi hosts host02 labels="['mon', 'mgr']" host03 labels="['mon', 'mgr']" host04 labels="['osd']" host05 labels="['osd']" host06 labels="['osd']" [admin] host01 monitor_address=10.10.128.68 labels="['_admin', 'mon', 'mgr']"
- Run the preflight playbook:
ansible-playbook -i INVENTORY_FILE cephadm-preflight.yml --extra-vars "ceph_origin=ibm"For example,
[ansible@admin cephadm-ansible]$ ansible-playbook -i hosts cephadm-preflight.yml --extra-vars "ceph_origin=ibm"" - Create a playbook to bootstrap your cluster.
sudo vi PLAYBOOK_FILENAME.yml --- - name: NAME_OF_PLAY hosts: BOOTSTRAP_HOST become: USE_ELEVATED_PRIVILEGES gather_facts: GATHER_FACTS_ABOUT_REMOTE_HOSTS tasks: -name: NAME_OF_TASK cephadm_registry_login: state: STATE registry_url: REGISTRY_URL registry_username: REGISTRY_USER_NAME registry_password: REGISTRY_PASSWORD - name: NAME_OF_TASK cephadm_bootstrap: mon_ip: "{{ monitor_address }}" dashboard_user: DASHBOARD_USER dashboard_password: DASHBOARD_PASSWORD allow_fqdn_hostname: ALLOW_FQDN_HOSTNAME cluster_network: NETWORK_CIDRFor example,
[ansible@admin cephadm-ansible]$ sudo vi bootstrap.yml --- - name: bootstrap the cluster hosts: host01 become: true gather_facts: false tasks: - name: login to registry cephadm_registry_login: state: login registry_url: cp.icr.io/cp registry_username: user1 registry_password: mypassword1 - name: bootstrap initial cluster cephadm_bootstrap: mon_ip: "{{ monitor_address }}" dashboard_user: mydashboarduser dashboard_password: mydashboardpassword allow_fqdn_hostname: true cluster_network: 10.10.128.0/28 - Run the playbook.
ansible-playbook -i INVENTORY_FILE PLAYBOOK_FILENAME.yml -vvvFor example,
ansible@admin cephadm-ansible]$ ansible-playbook -i hosts bootstrap.yml -vvv
Verification
Review the Ansible output after running the playbook.