How securityadmin.sh manages OpenSearch security configuration
Many teams change OpenSearch roles, role mappings and authentication backends by hand in Dashboards, and afterward nobody can say who changed what or why. OpenSearch security configuration lives in YAML files that are applied to the security index with securityadmin.sh. Treating those files as the source of truth lets a team review each change in version control, promote the same configuration through environments and reproduce a cluster's security state from a known starting point.
This approach fits when you run more than one cluster (for example, a test and a production cluster that must match), when auditors or internal reviewers expect a documented change history, or when security changes must pass a peer review before they reach production. The OpenSearch docs describe the security YAML files, including config.yml, roles.yml, roles_mapping.yml, internal_users.yml and action_groups.yml, as the files you edit before running the tool. Confirm the file set and key names against the version you run, because the docs and the plugin can change between releases. Read the Modifying the YAML files page before you write your first change.
The tool authenticates with an admin certificate, which is a separate trust boundary from ordinary user credentials. Decide who holds that certificate, where it is stored and who may run the script in production, because anyone who can apply configuration can grant themselves access. The Security plugin also exposes configuration version APIs, including rollback of the security configuration. Use them as a second recovery path alongside Git, and test both before you need them. The Configuration versions API page explains what the API returns and how a rollback is requested.
Which security YAML files hold which configuration
The config.yml file holds the authentication and authorization configuration. It defines which authentication domains the cluster accepts, the order in which it tries them, and where backend roles for a user are looked up. This is the file that connects the Security plugin to SAML, OpenID Connect, LDAP or Active Directory, Kerberos and JSON Web Token sources. Edit it using the structure described in the YAML configuration docs, section by section.
- Authentication domains: the ordered list of backends the cluster tries for each request, with the settings for each domain.
- Authorization backends: where the roles for a user are read from, such as a directory group lookup.
- Endpoint-specific settings: options that can differ between REST and transport traffic. Confirm the layout for your version.
- Endpoints and hostnames: identity provider URLs and directory hosts that change between environments, so store them as parameters, not literals.
Confirm every key against the documentation for your exact OpenSearch version before you change a domain order, because a mistake here can lock out every user, including administrators.
The roles.yml file defines the roles that control what an identity can do. Each role lists cluster permissions, index permissions and the index patterns they apply to. Document-level security queries, field-level security and field masking are also configured per role here. Because these entries decide who can read which data, they are the part of the configuration most likely to be reviewed by security and compliance teams.
- Cluster permissions: actions that apply to the whole cluster rather than to a named index.
- Index permissions and patterns: the actions allowed on each index pattern, so scope every pattern deliberately.
- Document and field controls: query-based restrictions and field rules that narrow what a role can see.
- Tenant permissions: access to OpenSearch Dashboards tenants, if your deployment uses them.
Roles should be changed through reviewed commits with a named owner for each role. Ask your platform team to confirm which permission types apply to writes in your version, because read restrictions and write restrictions are not always handled the same way.
The roles_mapping.yml file connects the roles defined in roles.yml to the people and systems that should receive them. A mapping can point to individual users, to backend roles supplied by an identity provider or directory, or to hosts and addresses in specific cases. This file is where an external group name becomes an OpenSearch permission, so it is a frequent source of unintended access when group names change upstream.
- User mappings: direct assignments of a role to named users, which should be rare and documented.
- Backend role mappings: links from groups or claims supplied by SAML, OpenID Connect or LDAP to a role.
- Host and address mappings: rules that match the origin of a request, if your setup needs them.
- Change control: a rename in the identity provider changes access without any change to OpenSearch, so review mappings whenever directory groups change.
Test each mapping with an account from every group that should and should not match before you apply it to a production cluster. Confirm the supported mapping keys in the YAML documentation for your version.
The internal_users.yml file defines users stored inside the Security plugin, along with their password hashes, backend roles and attributes. It matters most for local administrators, break-glass accounts and automation that does not sign in through an external provider. The file can be committed to version control, but only the hashed form of a password should ever appear in it. Plaintext passwords, private keys and other secrets should live in a secrets manager and be injected during deployment.
- Password hashes: store only the output of the hashing method described in the security documentation, never the plaintext value.
- Backend roles and attributes: labels that roles can match against, so keep their names consistent with
roles_mapping.yml. - Administrator accounts: keep the admin password and its recovery procedure in your secrets manager, outside the repository.
- Service accounts: list any non-human users here with a named owner, and move to scoped, revocable credentials where your version supports them.
Review this file for accounts that no longer have an owner. Confirm the exact hash format and field names for your OpenSearch version before you automate their creation.
The action_groups.yml file defines named sets of permissions that roles can reference instead of listing each action separately. The Security plugin ships with predefined groups, and you can add custom ones for your own patterns. Because many roles may depend on one group, a small edit here can change access across the cluster in a single apply.
- Predefined groups: the groups that ship with the plugin, which you should not edit casually.
- Custom groups: named bundles of actions that match how your teams describe their work, documented beside the roles that use them.
- Reference impact: list which roles reference each custom group, so a change can be reviewed in context.
- Naming: use stable, descriptive names, since renaming a group breaks every role that points to it.
Keep this file in the same repository as the other security files so that changes to groups and the roles that use them are reviewed together. Confirm the predefined group names and actions for your OpenSearch version in the YAML documentation before you rely on them.
How to apply changes with securityadmin.sh and an admin certificate
This sequence takes a change to the OpenSearch security configuration from a reviewed branch to a verified state on the cluster, using an admin certificate that the cluster recognizes. Each step ends with a check so the team knows the change applied and the affected access works.
Confirm the admin certificate and its distinguished name
The security engineer confirms which admin certificate will sign the securityadmin.sh call and that its distinguished name matches an entry in the cluster's admin certificate settings. The certificate must be issued by the CA the nodes trust and must be stored outside the Git repository, with restricted file permissions. Check the DN string character by character against the cluster configuration, because a mismatch is the most common reason the tool is refused. Confirm the exact admin DN setting and the flags for your version in the official securityadmin page before running anything. Done means you can read the DN from the certificate and find it in the cluster configuration.
Edit the security YAML files in a branch
An engineer creates a branch in the version-controlled repository and edits the relevant files in the security configuration directory, such as roles, roles_mapping, internal_users, config or the authentication backend definitions. Keep each change small enough that a reviewer can see which role, mapping or backend it touches. Validate the YAML syntax locally and review the diff, looking for accidental removals of admin or backend roles that could lock out operators. Done means the branch has a reviewed diff with a clear description of the access change.
Review the change and capture the current configuration
A second reviewer approves the merge request, and the team exports or records the currently applied configuration so there is a known-good baseline to return to. Use the configuration version APIs to note the current version before applying, since this is the point the team would roll back to if the change misbehaves. Done means the reviewer has approved the diff and the pre-change version number is written in the change record.
Run securityadmin.sh with the admin certificate
The operator runs securityadmin.sh from a host that can reach the cluster, pointing it at the directory of YAML files and authenticating with the admin certificate and key. The tool writes the files into the security index, so the operator should target the intended cluster and use a maintenance window if the change affects authentication. Confirm the flags for the target version, including how the configuration directory, cluster hostname and certificate paths are passed. Done means the command reports a successful update without errors.
Verify the applied configuration version
The operator checks that the configuration version increased and that the stored security configuration matches the files in the branch. Use the configuration version API to confirm the new version number and retrieve the active configuration for comparison with the reviewed YAML. Look for missing roles or mappings that did not survive the update. Done means the active configuration matches the reviewed change and the version number is recorded.
Test login and access with an affected role
A tester signs in as a user from each affected role and runs the queries the role is meant to allow and deny, including a check of any document-level or field-level restriction. Confirm that a denied action returns a permission error and that an allowed action succeeds. Also confirm that an admin account still works, so the team can make the next correction. Done means each affected role behaves as the reviewed change intended, with results written in the change record.
Roll back if a check fails
If a verification step fails, the operator reapplies the baseline configuration from the recorded version using the same securityadmin.sh method, or uses the configuration rollback capability described in the security API documentation for the version in use. The team then confirms the version and runs the login test again before reopening access. Record the failure, the version restored and the fix in a new branch. Done means the cluster returns to the last verified configuration and the failed change is queued for correction.
Version control practices that keep security changes reviewable
Security configuration in OpenSearch is a set of YAML files applied to the security index, so every role, mapping and backend change is effectively a production change. The practices below treat those files like code: they define where changes live, who reviews them, how they are tested, and how a given state can be identified and restored.
Separate repositories or branches per environment
Keep one source of truth for each cluster, either a repository per environment or a branch per environment with protected release branches. The goal is that a change merged for development cannot reach production by accident. Check that the production branch accepts changes only through reviewed merges, and that the files applied to each cluster match what the repository says they are.
Security YAML docsPeer review of role and mapping changes
Require a second engineer to approve any change to roles.yml, roles_mapping.yml or config.yml before merge. Reviewers should confirm the index patterns, document-level queries and field lists each role grants, not only the syntax. A diff that adds a backend role to a mapping is an access change and deserves the same scrutiny as a firewall rule.
Keep secrets and certificates out of YAML
The YAML files hold authorization logic, so they should not hold passwords, password hashes for real users, private keys or the admin certificate. Store those in a secrets manager or a restricted file path and inject them at apply time. Confirm that your repository scanning flags private key material and that the admin certificate is never committed, since anyone holding it can run securityadmin.sh.
Test changes on a non-production cluster first
Apply every security change to a non-production cluster with the same backends and index layout before production. Test the outcomes that matter: that the intended users can read and write the intended indices, that document-level and field-level rules hide what they should, and that existing dashboards still load. A test cluster with different backends will not catch mapping errors that only appear with real directory groups.
Tag each applied security state
Create a version control tag each time a security configuration is applied to production, and record the commit in the change ticket. When an access problem appears later, the tag tells you exactly which roles and mappings were live. Pair the tag with the configuration version that the Security plugin reports after the apply, so the repository state and the cluster state can be compared directly.
Configuration versions APIRecord who applied securityadmin.sh and when
Log every run of securityadmin.sh with the operator, the commit applied, the target cluster and the time. Because the tool uses an admin certificate rather than a named user session, the Security plugin audit trail may not show the human behind the change, so the apply log becomes the accountability record. Ask your team which system holds this log and how long it is retained.
securityadmin.sh docsHow a configuration change moves from Git to the security index
A change starts as YAML files in the Git repository, where it goes through review before anyone runs anything. An operator then applies the reviewed files to the cluster with securityadmin.sh, authenticated by an admin certificate that sits outside the repository. The Security plugin writes the result into the security index, and the configuration version history keeps the prior state so it can be rolled back. Check that the repository never holds the admin private key, and that the version history is read before any rollback.
Trust boundaries between the repository, the certificate holder and the cluster.
How configuration versions and rollback work
The Security plugin keeps its own record of configuration changes, and its configuration versions API includes rollback of the security configuration, so a bad change can be reverted inside the cluster as well as in Git. The two mechanisms answer different questions. Git history tells you what the files said and who changed them. The Security plugin's versions tell you what the live security index held at a point in time and let you return to it. Treat Git as the source of record and the plugin's versions as a fast recovery path for the running cluster. Before you rely on either, confirm the exact endpoints, request methods and payloads in the configuration versions API docs for the OpenSearch version you run, and confirm how many versions the target release retains, since retention determines how far back a rollback can go.
Choose the route by what went wrong. If a commit introduced a wrong role or mapping and the rest of the history is correct, revert the commit in Git and reapply the files with securityadmin.sh. This keeps the repository honest: the reverted change stays visible, the review trail is intact and the fix goes through the same pipeline as every other change. Roll back through the versions API when the live security configuration is broken and you need access restored quickly, for example after a mistaken update that locks out administrators. Rollback is the faster step, but it does not update your repository. Once the cluster is healthy, record the restored state in Git so that the next securityadmin.sh run does not silently reapply the bad files.
Rollback restores security settings, which means it can also restore an older access model: roles, mappings, backends and tenant permissions can all change back at once. Test the exact procedure on a non-production cluster loaded with the same YAML files and version, check that admin certificate access and a sample user's document-level restrictions behave as expected after rollback, and write down the steps. Do not assume a rollback is safe to run under load or during an incident without that rehearsal.
Which apply method fits each team's change process
This table compares three ways to apply security YAML changes: manual edits in Dashboards, scripted securityadmin.sh runs from a CI pipeline, and operator runs with a break-glass admin certificate. Read each row against your change approval process and your audit expectations, then pick the method that gives you reviewable, repeatable changes with a documented emergency path.
| Option | When it fits | What it requires | Main risk |
|---|---|---|---|
| Manual edits in Dashboards | Small teams making low-volume changes to users or roles while the configuration is not yet in version control | Admin access to Security in Dashboards and a named owner who records each change | Changes are hard to review, reproduce or trace back to an approved request |
| Scripted securityadmin.sh run from a CI pipeline | Teams that keep the YAML files in Git and want every change reviewed before it reaches the security index | A pipeline runner that can reach the cluster, a protected admin certificate, and pipeline support confirmed in your environment | Pipeline credentials or the admin certificate are exposed, or a merged change applies more than intended |
| Operator run with a break-glass admin certificate | Emergency recovery when normal access is lost or a lockout must be fixed quickly | A sealed, audited admin certificate, a documented runbook and a host where securityadmin.sh can run | The emergency path is used for routine changes and bypasses review |
| Operator run with a standard change ticket | Planned changes made by a platform engineer outside the pipeline | Access to the YAML files, the admin certificate and an approved change record | Drift between the files in Git and the live security index if the files are not updated afterward |
| Configuration version check before and after apply | Any method, to confirm which configuration version is live and to support rollback | Access to the configuration versions API for the security index | Teams skip the check and cannot tell which version a change produced |
Protecting the admin certificate and the security configuration
The admin certificate and the security YAML files decide who can change OpenSearch access rules, so they need the same care as production credentials. The cards below cover what can go wrong when securityadmin.sh runs and the controls to plan before the first apply.
Admin certificate grants full control
The admin certificate authenticates to the cluster as a superuser and can write to the security index, which means it can replace roles, users and backends. Treat it as a root credential: store the private key in a restricted secrets store, limit which hosts can read it, and avoid copying it to laptops or shared build images. Ask who can export it and whether each use is logged.
securityadmin.sh docsYAML files reveal access design
The files in the security configuration folder contain role logic, backend endpoints, hostnames and group names that help an attacker map your environment. Keep the repository private, scrub any real passwords or hashes from examples, and keep secrets in environment-specific inputs rather than in committed files. Check that the repository's access list matches the people who can approve security changes.
Bad applies can lock out administrators
A configuration that removes the admin role mapping, breaks the authentication backend or misspells a role name can leave no working login. Before applying, export the current configuration and test the new files against a non-production cluster with the same backends. Keep a documented break-glass account and confirm who can reach the cluster through the node network if Dashboards login fails.
Pipeline runners need narrow access
A CI runner that applies security changes holds the admin certificate for as long as the job runs, so a compromised runner can change access on the whole cluster. Give the runner a certificate that is issued for the job and expires soon after, scope its network path to the security endpoint only, and remove the key from the workspace when the job ends. Confirm that runner logs do not print the certificate or the YAML contents.
Separate authors from approvers
The person who edits a role mapping should not be the only person who approves and applies it. Require a protected branch, a second reviewer for changes under the security folder, and a separate group with the right to trigger the apply job. Record which commit was applied and by whom, so the audit trail links an access change to a reviewed change request.
Rollback depends on version history
When a change causes an access problem, you need to know which configuration version was active before it. The Security plugin exposes configuration version APIs with rollback, so check that your team can read the current version and restore a known-good state without relying on memory. Test this procedure in staging and document who is authorized to run it during an incident.
Configuration versions APIQuestions teams ask before applying security configuration as code
Can our own team apply OpenSearch security configuration as code without a partner?
Yes, if the team already runs OpenSearch and has someone comfortable with YAML, version control and an admin certificate. The securityadmin.sh workflow is documented, and the configuration lives in YAML files applied to the security index. The work that usually stalls a self-run project is not the commands but the inventory: finding roles and mappings that were created in Dashboards and never written down, deciding who owns each file, and proving that a change in Git produces the same state in the cluster. A partner is most useful when the cluster count is high or the existing state is undocumented. Confirm with your own administrators whether they have capacity for a test cluster and a review of the first export before deciding.
What makes a security configuration migration take longer?
Four drivers matter most. The first is cluster count, since each cluster needs its own apply path, test run and review. The second is the number of roles, role mappings and authentication backends, because each one must be exported, reviewed and reconciled. The third is existing manual drift: settings changed in Dashboards or through the API that do not match any file. The fourth is CI maturity. A team with pipelines, code review and protected branches can adopt the files quickly, while a team without them needs that tooling first. Ask any provider to break the quote down by these drivers and to state which of them it has assumed.
How long does a first migration to configuration as code take?
The supplied material does not give a duration for this work, so no figure should be relied on from this page. The honest answer depends on the drivers above. A single cluster with a short list of roles and one backend is a much smaller job than several clusters with directory-backed mappings and undocumented changes. Ask for a written plan that lists the clusters in scope, the export and review steps, the test cluster used for rehearsal, the cutover window and the acceptance checks. A timeline without those items is not something you can compare.
What access and inputs do we need to provide for this work?
The work needs several things from your side before it starts. You need an admin certificate and the ability to run securityadmin.sh against each target cluster, which means someone who owns the certificate authority or the admin key. You need a test cluster that matches production closely enough to rehearse applying the files. You need named owners for identity backends, such as the directory or identity provider team, because mappings depend on their group names. You also need a decision on where the YAML files will live and who may approve changes to them. Confirm each item in writing so that the first apply is not blocked by a missing credential.
How is rolling back security configuration different from restoring a snapshot?
Rolling back security configuration restores the access rules, roles, mappings and backends to an earlier configuration version, using the Security plugin's configuration version APIs. A snapshot restore brings back index data and, depending on what was captured, cluster state, but it is a much heavier operation and is not designed to undo a single access-control change. Use configuration versions for fast reversal of a bad role or mapping change, and keep snapshots for data recovery. Test both paths on the test cluster, because a rollback that works on paper can still leave dependent indices or applications in an unexpected state.
Does configuration as code remove the need for access reviews?
No. Version control shows who changed a role or mapping and when, and it makes review possible, but it does not decide whether an access grant is correct. Someone still has to approve each change against the business need for the data. Configuration as code also does not protect the admin certificate or the Git repository that holds the files, so those need the same controls as any other production credential. Treat the repository as a control point and agree who may merge changes and who holds the key that applies them.
What should we check first in our current cluster before exporting it?
Start by listing what exists and what is written down. Check the security index for roles, role mappings, internal users, action groups and authentication backends, and compare them with any files you already keep. Look for demo settings left from installation, which may not match your intended production state. Identify who created each role and whether the owner still exists. Record the configuration version currently in place so you have a known point to return to. This inventory is the basis for estimating effort and the most useful thing to share with any provider or internal reviewer.
How DeployOpen helps teams move security configuration into version control
DeployOpen starts this work with a written scope agreed before any change is made to the cluster. The first step is an inventory of what the cluster holds today: every role in roles.yml, every backend in config.yml (SAML, OpenID Connect, LDAP or Active Directory, and any Kerberos or JSON Web Token setup), the role mappings in roles_mapping.yml, and the internal users in internal_users.yml. Many production clusters have drifted from their install-time files because roles were edited in Dashboards or through the API, so this inventory is often where the first surprises appear. The scope also records which teams own which files, who may approve a change, and which environments the repository must cover.
Next, DeployOpen defines the repository and review model with your team: how the security YAML files are laid out, how changes are proposed and reviewed, and who holds the admin certificate that securityadmin.sh needs to write to the security index. The first apply runs against a test cluster built to match production, so the team can see exactly what the command replaces and confirm the result with the Security plugin APIs before any production cluster is touched. The rollback procedure is written and rehearsed at this stage, using the configuration version APIs to restore a prior security configuration, so that the team knows the steps before they need them. Confirm the exact commands and API behavior against the current OpenSearch documentation for your version.
All of this work happens inside your own cloud accounts, data centers or air-gapped networks, and DeployOpen does not need a copy of your security configuration held outside them. Once the repository and runbook are in place, ongoing support can be added as a retainer for reviewing changes, applying updates across versions and rehearsing rollback after upgrades. Ask any partner for the written scope, the named deliverables and the handover terms before work begins, because those determine what your team can maintain alone afterward.
How DeployOpen works on this
DeployOpen plans, implements, documents and supports self-hosted OpenSearch inside your own infrastructure, including the security YAML files, the securityadmin.sh process and the admin certificate that apply them. Engagements start with a written scope so that roles, backends, change control and rollback are agreed before any configuration is changed.
How we scope
- Inventory the current security YAML files, roles, role mappings, internal users and authentication backends before any change is planned.
- Agree in writing which files move into version control, who approves changes and where the admin certificate is kept.
- Define the target environments, such as development, test and production, and how configuration moves between them.
- Engagements are fixed-scope, so deliverables and timelines are confirmed in writing before work starts.
How we build
- Structure the repository so roles, role mappings, action groups, tenants and backends are reviewed as code changes.
- Run securityadmin.sh against a non-production cluster first, then confirm the applied configuration matches the repository.
- Test that role permissions, document and field restrictions and tenant access behave as the written design says.
- Record the configuration version before each apply so a known-good state can be identified if a change fails.
How we hand over
- Deliver the repository, a runbook for applying changes with securityadmin.sh and a documented admin certificate procedure.
- Document how to check the active configuration version, review drift and roll back using the configuration versions API.
- Walk your platform and security teams through the approval workflow, including who may run the script in production.
- Provide written records of what was changed, when, and which configuration version each change produced.
How we support
- Ongoing support, upgrades and continuous testing are available as retainers, scoped in writing.
- A retainer can cover reviews of proposed role and backend changes before they reach production.
- Security configuration can be retested after OpenSearch version upgrades, which change the security plugin as well as the cluster.
- Ask for the support scope, response expectations and upgrade handling in the written quote, since these vary by agreement.

