---
title: Charmhub | Deploy MongoDB using Charmhub - The Open Operator Collection
description: Deploy the latest version of MongoDB on any cloud.
url: https://charmhub.io/mongodb/libraries/machine_helpers
---

# MongoDB

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

24.04

22.04

6/stable 265

```
juju deploy mongodb --channel 6/stable
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

[Toggle side navigation](https://charmhub.io/mongodb/libraries/machine_helpers#drawer)

## charms.mongodb.v0.machine\_helpers

* [*Docstrings*Docstrings](https://charmhub.io/mongodb/libraries/machine_helpers)
  [*Code*Source code](https://charmhub.io/mongodb/libraries/machine_helpers/source-code)
* + Download

    Fetch library

    ```
    charmcraft fetch-lib charms.mongodb.v0.machine_helpers
    ```

    [Download machine\_helpers.py](https://charmhub.io/mongodb/libraries/machine_helpers/download)
  + *Last updated* 11 Oct 2022
  + *Revision* Library version 0.1

Machine Charm specific functions for operating MongoDB.

---

Index

* [def auth\_enabled(
  )](https://charmhub.io/mongodb/libraries/machine_helpers#auth_enabled)
* [def start\_with\_auth(
  path
  )](https://charmhub.io/mongodb/libraries/machine_helpers#start_with_auth)
* [def stop\_mongod\_service(
  )](https://charmhub.io/mongodb/libraries/machine_helpers#stop_mongod_service)
* [def start\_mongod\_service(
  )](https://charmhub.io/mongodb/libraries/machine_helpers#start_mongod_service)
* [def update\_mongod\_service(
  auth,
  machine\_ip,
  config
  )](https://charmhub.io/mongodb/libraries/machine_helpers#update_mongod_service)
* [def add\_self\_healing(
  service\_lines
  )](https://charmhub.io/mongodb/libraries/machine_helpers#add_self_healing)
* [def generate\_service\_args(
  auth,
  machine\_ip,
  config
  )](https://charmhub.io/mongodb/libraries/machine_helpers#generate_service_args)
* [def push\_file\_to\_unit(
  parent\_dir,
  file\_name,
  file\_contents
  )](https://charmhub.io/mongodb/libraries/machine_helpers#push_file_to_unit)
* [def restart\_mongod\_service(
  auth,
  machine\_ip,
  config
  )](https://charmhub.io/mongodb/libraries/machine_helpers#restart_mongod_service)
* [class ApplicationHostNotFoundError](https://charmhub.io/mongodb/libraries/machine_helpers#applicationhostnotfounderror)

#### def auth\_enabled()

Description

Checks if mongod service is has auth enabled. None

#### def start\_with\_auth(path)

Description

Returns true is a mongod service file has the auth configuration. None

#### def stop\_mongod\_service()

Description

Stop the mongod service if running. None

#### def start\_mongod\_service()

Description

Starts the mongod service if stopped. None

#### def update\_mongod\_service(     auth: bool,     machine\_ip: str,     config: MongoDBConfiguration )

Description

Updates the mongod service file with the new options for starting. None

#### def add\_self\_healing(service\_lines)

Updates the service file to auto-restart the DB service on service failure.

Description

Options for restarting allow for auto-restart on crashed services, i.e. DB killed, DB frozen,
DB terminated.

#### def generate\_service\_args(     auth: bool,     machine\_ip: str,     config: MongoDBConfiguration )

Construct the mongod startup commandline args for systemd.

Description

Note that commandline arguments take priority over any user set config file options. User
options will be configured in the config file. MongoDB handles this merge of these two
options.

#### def push\_file\_to\_unit(     parent\_dir,     file\_name,     file\_contents )

Description

K8s charms can push files to their containers easily, this is the vm charm workaround. None

#### def restart\_mongod\_service(     auth: bool,     machine\_ip: str,     config: MongoDBConfiguration )

Description

Restarts the mongod service with its associated configuration. None

#### class ApplicationHostNotFoundError

Description

Raised when a queried host is not in the application peers or the current host. None
