community.hrobot.storagebox_subaccount module – Create, update, or delete a subaccount for a storage box
Note
This module is part of the community.hrobot collection (version 2.5.2).
You might already have this collection installed if you are using the ansible package.
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install community.hrobot.
To use it in a playbook, specify: community.hrobot.storagebox_subaccount.
New in community.hrobot 2.4.0
Synopsis
- Create, update, or delete a subaccount for a storage box. 
Parameters
| Parameter | Comments | 
|---|---|
| A custom comment for the subaccount. Is required when using  | |
| Enable or disable external reachability (from outside Hetzner’s networks). Choices: 
 | |
| The password for the Robot web-service user. If  | |
| The API token for the Robot web-service user. One of  | |
| The username for the Robot web-service user. One of  If  | |
| Home directory of the subaccount. Required only when creating a subaccount ( | |
| Select which attribute to use to check subaccount existence. If set to  If set to  Choices: 
 | |
| Password to use or change. See  Will be ignored if  | |
| Controls how password updates are handled. If  If  If  When a new subaccount is created, the password is set to the specified one if  Choices: 
 | |
| Timeout (in seconds) for waiting when rate limit exceeded errors are returned. Set to  Set to a negative value like  Default:  | |
| Enable or disable read-only mode. Choices: 
 | |
| Enable or disable Samba. Choices: 
 | |
| Enable or disable SSH access. Choices: 
 | |
| Desired state of this subaccount. Choices: 
 | |
| The ID of the storage box to query. | |
| Username of the subaccount. Required when using  If  | |
| Enable or disable WebDAV. Choices: 
 | 
Attributes
| Attribute | Support | Description | 
|---|---|---|
| Action groups: community.hrobot.api, community.hrobot.robot | Use  | |
| Support: full | Can run in  | |
| Support: none | Will return details on what has changed (or possibly needs changing in  | |
| Support: partial The Hetzner API does not allow to create subaccounts with specific usernames. You can instead use  The module is never idempotent if  | When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change. This assumes that the system controlled/queried by the module has not changed in a relevant way. | 
Notes
Note
- When passwords are autogenerated by the API (by omitting the - passwordfield), the resulting password is returned.
Examples
---
- name: Create a new subaccount with random password
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    homedirectory: "/backups/project1"
    samba: true
    ssh: true
    webdav: false
    comment: "Backup for Project 1"
- name: Create a subaccount with custom password
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    username: "backup1"
    password: "s3cretPass123"
    homedirectory: "/data/backup1"
    readonly: false
    samba: true
    ssh: false
- name: Update an existing subaccount
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    state: present
    username: "backup1"
    homedirectory: "/data/backup1-updated"
    readonly: true
    comment: "Updated path and readonly mode"
- name: Delete a subaccount
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    state: absent
    username: "backup1"
- name: Change password for a subaccount
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    state: present
    username: "backup1"
    password: "n3wSecur3Pass"
- name: Create subaccount using comment for idempotence
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    homedirectory: "/projects/backup1"
    samba: true
    ssh: true
    webdav: false
    readonly: false
    comment: "Backup1 - Project Foo"
    idempotence: comment
- name: Update subaccount identified by comment
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    homedirectory: "/projects/backup1-updated"
    readonly: true
    comment: "Backup1 - Project Foo"
    idempotence: comment
- name: Update password for subaccount using comment idempotence
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    password: "Sup3rSecur3!"
    comment: "Backup1 - Project Foo"
    idempotence: comment
    password_mode: update-if-provided
- name: Delete subaccount identified by comment
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    state: absent
    comment: "Backup1 - Project Foo"
    idempotence: comment
- name: Use password only during creation
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    password: "InitPass$42"
    homedirectory: "/mnt/init"
    samba: true
    ssh: false
    comment: "Init Subaccount"
    idempotence: comment
    password_mode: ignore-if-exists
- name: Always reset to a random password
  community.hrobot.storagebox_subaccount:
    storagebox_id: 123456
    comment: "Temp Access - CI/CD"
    idempotence: comment
    password_mode: set-to-random
Return Values
Common return values are documented here, the following are the fields unique to this module:
| Key | Description | 
|---|---|
| Whether a new subaccount was created. Returned: success | |
| Whether the subaccount was deleted. Returned: success | |
| Whether the subaccount’s password was updated. Returned: success | |
| The subaccount object returned by the API. If  Returned: if  | |
| Whether the subaccount’s configuration was updated (excluding password changes). Returned: success | 
