Skip to content

Commit

Permalink
Support for mongodb v7 (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
trfore authored Apr 2, 2024
2 parents c2d81cb + be7e693 commit 7f61e6e
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 41 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@ on:
default: false
required: true
type: boolean
pull_request:
branches: [main]
types: [closed]
paths-ignore:
- "LICENSE"
- "README.md"
release:
types: [published]

jobs:
deploy:
if: ${{ github.event.pull_request.merged == true || inputs.manual_deploy == true }}
if: ${{ github.event.release.published == true || inputs.manual_deploy == true }}
uses: trfore/ansible-role/.github/workflows/deploy_ansible_galaxy.yml@main # remote repo
secrets:
API_KEY: ${{ secrets.GALAXY_API_KEY }}
30 changes: 18 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,24 +53,29 @@ jobs:
strategy:
fail-fast: false
matrix:
distro: [centos8, debian10, debian11, ubuntu2004]
distro: [centos8, debian10, debian11, ubuntu2004, ubuntu2204]
version: ["6.0.14"]
experimental: [false]
molecule_scenario: ["-s default", "-s install_tarball"]
include:
- distro: ubuntu2204
version: "6.0.14"
experimental: false
molecule_scenario: "-s default"
- distro: ubuntu2204
version: "6.0.14"
experimental: true
molecule_scenario: "-s install_tarball"
uses: ./.github/workflows/test.yml
with:
distro: ${{ matrix.distro }}
version: ${{ matrix.version }}
experimental: ${{ matrix.experimental }}
molecule_scenario: ${{ matrix.molecule_scenario }}

v7_test:
needs:
- lint_ansible
- lint_python
strategy:
fail-fast: false
matrix:
distro: [centos8, debian11, debian12, ubuntu2004, ubuntu2204]
version: ["7.0.7"]
molecule_scenario: ["-s default", "-s install_tarball"]
uses: ./.github/workflows/test.yml
with:
distro: ${{ matrix.distro }}
version: ${{ matrix.version }}
molecule_scenario: ${{ matrix.molecule_scenario }}

build_results:
Expand All @@ -80,6 +85,7 @@ jobs:
- v4_test
- v5_test
- v6_test
- v7_test
steps:
- name: All builds passed
if: ${{ !(contains(needs.*.result, 'failure')) }}
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/update_mongodb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
sudo bash .github/workflows/scripts/add_mongodb_repo.sh
# get current and latest versions, update files if needed
VERSION=(4.4 5.0 6.0)
VERSION=(4.4 5.0 6.0 7.0)
for i in "${VERSION[@]}"; do
maj=${i%.*}
latest=$(apt-cache show mongodb-org | grep -om1 "^Version:\s"${i}"\.[0-9]*$" | awk '{print $2}')
Expand All @@ -44,7 +44,8 @@ jobs:
--arg v4 "$latest_v4" \
--arg v5 "$latest_v5" \
--arg v6 "$latest_v6" \
'{"4.4": $v4, "5.0": $v5, "6.0": $v6}' >mongodb.versions
--arg v7 "$latest_v7" \
'{"4.4": $v4, "5.0": $v5, "6.0": $v6, "7.0": $v7}' >mongodb.versions
echo "MongoDB version check complete, updated to latest versions"
else
Expand Down
21 changes: 14 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ roles:
## Tested Platforms and Versions
### MongoDB Community `7.0.7`

- CentOS Stream 8
- Debian 11 & 12
- Ubuntu 20.04 & 22.04

### MongoDB Community `6.0.14`

- CentOS Stream 8
Expand Down Expand Up @@ -61,12 +67,12 @@ roles:

Common variables are listed below, along with default values (see `defaults/main.yml`):

| Variable | Default | Description | Required |
| ------------------------- | --------- | ------------------------------------------------------ | --------- |
| mongodb_pkg_install | `true` | Boolean, `true` to install MongoDB via package manager | No |
| mongodb_version | `4.4.29` | MongoDB Community stable releases `v4.4`, `v5`, `v6` | Yes |
| mongodb_version_maj | Automatic | Extracts major value from `mongodb_version` | Automatic |
| mongodb_version_maj_minor | Automatic | Extracts major and minor values from `mongodb_version` | Automatic |
| Variable | Default | Description | Required |
| ------------------------- | --------- | ---------------------------------------------------------- | --------- |
| mongodb_pkg_install | `true` | Boolean, `true` to install MongoDB via package manager | No |
| mongodb_version | `4.4.29` | MongoDB Community stable releases `v4.4`, `v5`, `v6`, `v7` | No |
| mongodb_version_maj | Automatic | Extracts major value from `mongodb_version` | Automatic |
| mongodb_version_maj_minor | Automatic | Extracts major and minor values from `mongodb_version` | Automatic |

### Package Install Variables

Expand All @@ -76,7 +82,7 @@ Common variables are listed below, along with default values (see `defaults/main
| --------------------- | ---------------- | --------------------------------------------------------------------- | -------- |
| mongodb_gpg_key | URL | MongoDB GPG Key | No |
| mongodb_pkg_hold | `true` | Boolean, `true` to hold package version | No |
| mongodb_pkg_hold_list | MongoDB Packages | List of MongoDB packages installed from `mongodb-org`, `v4.4` to `v6` | No |
| mongodb_pkg_hold_list | MongoDB Packages | List of MongoDB packages installed from `mongodb-org`, `v4.4` to `v7` | No |

### Binary Install Variables

Expand Down Expand Up @@ -189,6 +195,7 @@ Taylor Fore (https://github.com/trfore)

### MongoDB

- https://www.mongodb.com/docs/manual/release-notes/
- https://www.mongodb.com/download-center/community/releases
- https://www.mongodb.com/docs/manual/administration/install-on-linux/
- https://www.mongodb.com/docs/manual/administration/production-notes/
Expand Down
9 changes: 3 additions & 6 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ galaxy_info:

license: MIT

min_ansible_version: '2.14'
min_ansible_version: "2.14"

platforms:
- name: Debian
versions: [buster, bullseye]
- name: EL
versions: ['8']
versions: ["8"]
- name: Ubuntu
versions: [focal, jammy]

galaxy_tags:
- database
- mongo
- mongodb
galaxy_tags: [database, mongo, mongodb]

dependencies:
[]
Expand Down
3 changes: 3 additions & 0 deletions molecule/install_tarball/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
when: ansible_os_family == 'Debian'
changed_when: false

- name: Install tzdata to populate /usr/share/zoneinfo
ansible.builtin.package:
name: tzdata
tasks:
- name: 'Include ansible-role-mongodb-install'
ansible.builtin.include_role:
Expand Down
3 changes: 2 additions & 1 deletion mongodb.versions
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"4.4": "4.4.29",
"5.0": "5.0.26",
"6.0": "6.0.14"
"6.0": "6.0.14",
"7.0": "7.0.7"
}
24 changes: 18 additions & 6 deletions tasks/tarball-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,24 @@
loop_var: mongodb_path

- name: Create MongoDB config
ansible.builtin.template:
src: mongod.conf.j2
dest: /etc/mongod.conf
mode: '0644'
owner: root
group: root
block:
- name: Create basic mongo.conf (v4 to v6)
ansible.builtin.template:
src: mongod.conf.j2
dest: /etc/mongod.conf
mode: '0644'
owner: root
group: root
when: mongodb_version_maj in ["4", "5", "6"]

- name: Create basic mongo.conf (v7)
ansible.builtin.template:
src: mongod_v7.conf.j2
dest: /etc/mongod.conf
mode: '0644'
owner: root
group: root
when: mongodb_version_maj == "7"

- name: Create MongoDB service
ansible.builtin.template:
Expand Down
34 changes: 34 additions & 0 deletions templates/mongod_v7.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# mongod.conf

# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
dbPath: {{ mongodb_path_db }}
# engine:
# mmapv1:
# wiredTiger:

# where to write logging data.
systemLog:
destination: file
logAppend: true
path: {{ mongodb_path_log }}/mongod.log

# network interfaces
net:
port: 27017
bindIp: 127.0.0.1

# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo

#security:

#operationProfiling:

#replication:

#sharding:
9 changes: 9 additions & 0 deletions vars/redhat_mongo_v7.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
mongodb_pkg_hold_list:
- mongodb-database-tools
- mongodb-mongosh
- mongodb-org
- mongodb-org-database
- mongodb-org-database-tools-extra
- mongodb-org-mongos
- mongodb-org-server
- mongodb-org-tools

0 comments on commit 7f61e6e

Please sign in to comment.