Imported from serverscom/serverscom-ansible (
AGENTS.md). Install upstream withnpx skills add serverscom/serverscom-ansible. Copyright stays with the author.
Serverscom Ansible Collection
Project Overview
Ansible collection providing modules for the Servers.com public API, https://developers.servers.com/api-documentation/v1/ It's used to manage baremetal servers, cloud computing instances, SSH keys, L2 segments, load balancers, and RBS (Remote Block Storage) volumes.
There are two types of baremetal: Enterprise Baremetal (dedicated) and Scalable Baremetal (SBM).
Structure
-
Location: Collections is in
ansible_collections/serverscom/sc_api/. In it: -
plugins/modules/- 40+ modules, thin wrappers that parse args and delegate to handler classes in module_utils -
plugins/module_utils/, code is split per resource type.- api.py - API layer:
ApiHelper(HTTP/auth/retry/pagination) →ScApi(high-level API methods) +ScApiToolbox(name/regex lookups) - modules.py - Common code
- sbm.py
- cloud_computing.py
- dedicated_server.py
- l2_segment.py
- load_balancer.py
- rbs.py
- ssh_key.py
- api.py - API layer:
-
Doc fragments:
plugins/doc_fragments/api_auth.py- sharedtoken/endpointdocs with env var fallback documentation (used by all modules viaextends_documentation_fragment)
Key Patterns
- Module naming:
<resource>or<resource>_info(info modules are read-only). Oldsc_prefixed names work as aliases viaplugin_routinginmeta/runtime.yml, only for old modules. New are created without an alias. - Module structure: Each module creates a handler class instance and calls
.run()insidetry/except SCBaseError, usinge.fail()on error - API client layers:
ScApi(API methods) →ApiHelper(HTTP, Bearer auth, retry, pagination) →ScApiToolbox(convenience lookups by name/regex) - Error handling:
APIError400,APIError401,APIError404,APIError409,DecodeError— all carrycorrelation_idand have.fail()returning structured dict - Wait/retry: Handler classes poll API with
retry_rules(retries on 429 rate-limit and 500);WaitErroron timeout - Parameters: All modules require
tokenand acceptendpoint. Both support env var fallback viaenv_fallback: token falls back toSERVERSCOM_API_TOKENthenSC_TOKEN; endpoint falls back toSERVERSCOM_API_URL. Action modules often supportwait/update_interval, common module arguments are called AUTH_ARGS. - Module parameter naming: All
_idparams need_name/_regexalternatives. Module resolves to IDs internally. Examples:server_id/server_hostname/server_regex,flavor_id/flavor_name,location_id/location_code
Testing
To run quick tests (sanity, unit, non-secret integration tests), run just quick-tests
There are other slow and expensive integration tests, do not run them, you don't have access to secrets. Don't try to get access to them.
Integration tests should use variables to reference existing objects (defined in @integration_config.yml.template)
Libraries: ansible-provided and requests. CI: Github Actions .github/workflows/tests.yaml