<a id="how-to-redeploy"></a>

# How to redeploy

Because the osquery charm is stateless, redeploying it is straightforward: remove
the application and deploy it again against the same principal. The agent
re-enrolls with the osquery controller once its configuration is reapplied.

<!-- vale Canonical.013-Spell-out-numbers-below-10 = NO -->

## Capture the current configuration

Before removing the application, capture its configuration so you can reapply it:

```bash
juju config osquery > osquery-config-backup.yaml
```

## Remove the existing application

Remove the osquery subordinate. This leaves the principal application untouched:

```bash
juju remove-application osquery
```

## Deploy and integrate again

Deploy the charm again and integrate it with the same principal application:

```bash
juju deploy osquery
juju integrate <principal-application> osquery
```

## Reapply the configuration

Reapply the configuration you captured earlier, including the controller
settings, enrollment secret, and TLS certificates. See the [advanced
tutorial](https://canonical.com/juju/docs/osquery-charm/latest/tutorial/advanced-deployment/index.html.md#tutorial-advanced-deployment) for the full set of options.

Confirm that the charm settles into an `active` state:

```bash
juju status --watch 2s
```
