Adding and removing hosts

Add and remove hosts in your storage cluster by using the ceph_orch_host module in your Ansible playbook.

Before you begin

Before you begin, make sure that you have the following prerequisites in place:
  • A running IBM Storage Ceph cluster.
  • Register the nodes to the CDN and attach subscriptions.
  • Ansible user with sudo and passwordless SSH access to all nodes in the storage cluster.
  • Installation of the cephadm-ansible package on the Ansible administration node.
  • New hosts have the storage cluster’s public SSH key.

    For more information about copying the storage cluster's public SSH keys to new hosts, see Adding hosts.

Adding hosts

Add new hosts to the storage cluster.

Procedure

  1. Log in to the Ansible administration node.
  2. Navigate to the /usr/share/cephadm-ansible directory on the Ansible administration node.
    For example,
    [ansible@admin ~]$ cd /usr/share/cephadm-ansible
  3. Add the new hosts and labels to the Ansible inventory file.
    Note: If you have previously added the new hosts to the Ansible inventory file and ran the preflight playbook on the hosts, skip to step 5.
    sudo vi INVENTORY_FILE
    
    NEW_HOST1 labels="['LABEL1', 'LABEL2']"
    NEW_HOST2 labels="['LABEL1', 'LABEL2']"
    NEW_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']"
  4. Run the preflight playbook with the --limit option.
    ansible-playbook -i INVENTORY_FILE cephadm-preflight.yml --extra-vars "ceph_origin=ibm" --limit NEWHOST
    For example,
    [ansible@admin cephadm-ansible]$ ansible-playbook -i hosts cephadm-preflight.yml --extra-vars "ceph_origin=ibm" --limit host02
    The preflight playbook installs podman, lvm2, chrony, and cephadm on the new host. After installation is complete, cephadm resides in the /usr/sbin/ directory.
  5. Create a playbook to add the new hosts to the cluster.
    sudo vi PLAYBOOK_FILENAME.yml
    
    ---
    - name: PLAY_NAME
      hosts: HOSTS_OR_HOST_GROUPS
      become: USE_ELEVATED_PRIVILEGES
      gather_facts: GATHER_FACTS_ABOUT_REMOTE_HOSTS
      tasks:
        - name: NAME_OF_TASK
          ceph_orch_host:
            name: "{{ ansible_facts[hostname] }}"
            address: "{{ ansible_facts[default_ipv4][address] }}"
            labels: "{{ labels }}"
          delegate_to: HOST_TO_DELEGATE_TASK_TO
    
        - name: NAME_OF_TASK
          when: inventory_hostname in groups[admin]
          ansible.builtin.shell:
            cmd: CEPH_COMMAND_TO_RUN
          register: REGISTER_NAME
    
        - name: NAME_OF_TASK
          when: inventory_hostname in groups[admin]
          debug:
            msg: "{{ REGISTER_NAME.stdout }}"
    Note: By default, Ansible runs all tasks on the host that matches the hosts line of your playbook. The ceph orch commands must run on the host that contains the admin keyring and the Ceph configuration file. Use the delegate_to keyword to specify the admin host in your cluster.
    In the following example, the playbook adds the new hosts to the cluster and displays a current list of hosts.
    [ansible@admin cephadm-ansible]$ sudo vi add-hosts.yml
    
    ---
    - name: add additional hosts to the cluster
      hosts: all
      become: true
      gather_facts: true
      tasks:
        - name: add hosts to the cluster
          ceph_orch_host:
            name: "{{ ansible_facts['hostname'] }}"
            address: "{{ ansible_facts['default_ipv4']['address'] }}"
            labels: "{{ labels }}"
          delegate_to: host01
    
        - name: list hosts in the cluster
          when: inventory_hostname in groups['admin']
          ansible.builtin.shell:
            cmd: ceph orch host ls
          register: host_list
    
        - name: print current list of hosts
          when: inventory_hostname in groups['admin']
          debug:
            msg: "{{ host_list.stdout }}"
  6. Run the playbook to add additional hosts to the cluster.
    ansible-playbook -i INVENTORY_FILE PLAYBOOK_FILENAME.yml
    For example,
    [ansible@admin cephadm-ansible]$ ansible-playbook -i hosts add-hosts.yml

What to do next

Review the Ansible task output displaying the current list of hosts in the cluster.
For example,
TASK [print current hosts] ******************************************************************************************************
Friday 24 April 2026  14:52:40 -0400 (0:00:03.365)       0:02:31.702 ***********
ok: [host01] =>
  msg: |-
    HOST    ADDR           LABELS          STATUS
    host01  10.10.128.68   _admin mon mgr
    host02  10.10.128.69   mon mgr
    host03  10.10.128.70   mon mgr
    host04  10.10.128.71   osd
    host05  10.10.128.72   osd
    host06  10.10.128.73   osd

Removing hosts

Remove hosts from the cluster.

Procedure

  1. Log in to the Ansible administration node.
  2. Navigate to the /usr/share/cephadm-ansible directory on the Ansible administration node.
    For example,
    [ansible@admin ~]$ cd /usr/share/cephadm-ansible
  3. Create a playbook to remove a host or multiple hosts from the cluster.
    sudo vi PLAYBOOK_FILENAME.yml
    
    ---
    - name: NAME_OF_PLAY
      hosts: ADMIN_HOST
      become: USE_ELEVATED_PRIVILEGES
      gather_facts: GATHER_FACTS_ABOUT_REMOTE_HOSTS
      tasks:
        - name: NAME_OF_TASK
          ceph_orch_host:
            name: HOST_TO_REMOVE
            state: STATE
    
        - name: NAME_OF_TASK
          ceph_orch_host:
            name: HOST_TO_REMOVE
            state: STATE
          retries: NUMBER_OF_RETRIES
          delay: DELAY
          until: CONTINUE_UNTIL
          register: REGISTER_NAME
    
        - name: NAME_OF_TASK
          ansible.builtin.shell:
            cmd: ceph orch host ls
          register: REGISTER_NAME
    
        - name: NAME_OF_TASK
            debug:
              msg: "{{ REGISTER_NAME.stdout }}"
    In the following example, the playbook tasks drain all daemons on host07, removes the host from the cluster, and displays a current list of hosts.
    [ansible@admin cephadm-ansible]$ sudo vi remove-hosts.yml
    
    ---
    - name: remove host
      hosts: host01
      become: true
      gather_facts: true
      tasks:
        - name: drain host07
          ceph_orch_host:
            name: host07
            state: drain
    
        - name: remove host from the cluster
          ceph_orch_host:
            name: host07
            state: absent
          retries: 20
          delay: 1
          until: result is succeeded
          register: result
    
         - name: list hosts in the cluster
           ansible.builtin.shell:
             cmd: ceph orch host ls
           register: host_list
    
         - name: print current list of hosts
           debug:
             msg: "{{ host_list.stdout }}"
  4. Run the playbook to remove the hosts from the cluster.
    ansible-playbook -i INVENTORY_FILE PLAYBOOK_FILENAME.yml
    For example,
    [ansible@admin cephadm-ansible]$ ansible-playbook -i hosts remove-hosts.yml

What to do next

Review the Ansible task output displaying the current list of hosts in the cluster.
For example,
TASK [print current hosts] ******************************************************************************************************
Friday 24 April 2026  14:52:40 -0400 (0:00:03.365)       0:02:31.702 ***********
ok: [host01] =>
  msg: |-
    HOST    ADDR           LABELS          STATUS
    host01  10.10.128.68   _admin mon mgr
    host02  10.10.128.69   mon mgr
    host03  10.10.128.70   mon mgr
    host04  10.10.128.71   osd
    host05  10.10.128.72   osd
    host06  10.10.128.73   osd