Initial commit
Some checks failed
Ansible Playbook lint & deploy / ansible-lint (push) Successful in 12s
Ansible Playbook lint & deploy / run-ansible-mongo (push) Failing after 6s
Ansible Playbook lint & deploy / run-ansible-postgres (push) Failing after 7s

This commit is contained in:
2024-12-03 00:56:20 +00:00
commit 32d815621d
29 changed files with 465 additions and 0 deletions

View File

@@ -0,0 +1 @@
vm.swappiness = 1

View File

@@ -0,0 +1,37 @@
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /var/lib/mongodb
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
# network interfaces
net:
port: 27017
# bindIp: 127.0.0.1
bindIp: 0.0.0.0
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:

View File

@@ -0,0 +1,5 @@
---
- name: Restart mongodb
ansible.builtin.systemd_service:
name: mongodb.service
state: restarted

View File

@@ -0,0 +1,45 @@
---
- name: Configure swappiness
ansible.builtin.copy:
src: 99-swappiness.conf
dest: /etc/sysctl.d/99-swappiness.conf
mode: '0644'
owner: root
group: root
- name: Install mongodb
block:
- name: Check if mongodb up
ansible.builtin.systemd_service:
name: mongodb.service
state: started
check_mode: true
rescue:
- name: Install mongodb config
ansible.builtin.copy:
src: mongodb.conf
dest: /etc/mongodb.conf
mode: '0644'
owner: root
group: root
- name: Start and enable mongodb
ansible.builtin.systemd_service:
name: mongodb.service
state: started
enabled: true
- name: Setup admin account
community.mongodb.mongodb_user:
database: admin
name: root
password: "{{ mongodb_root_password }}"
state: present
roles: root
- name: Apply authorization
ansible.builtin.blockinfile:
path: /etc/mongodb.conf
block: |
security:
authorization: "enabled"
notify: Restart mongodb
- name: Flush handlers
ansible.builtin.meta: flush_handlers