Initial commit
This commit is contained in:
1
roles/configure_mongo/files/99-swappiness.conf
Normal file
1
roles/configure_mongo/files/99-swappiness.conf
Normal file
@@ -0,0 +1 @@
|
||||
vm.swappiness = 1
|
||||
37
roles/configure_mongo/files/mongodb.conf
Normal file
37
roles/configure_mongo/files/mongodb.conf
Normal 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:
|
||||
5
roles/configure_mongo/handlers/main.yml
Normal file
5
roles/configure_mongo/handlers/main.yml
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
- name: Restart mongodb
|
||||
ansible.builtin.systemd_service:
|
||||
name: mongodb.service
|
||||
state: restarted
|
||||
45
roles/configure_mongo/tasks/main.yml
Normal file
45
roles/configure_mongo/tasks/main.yml
Normal 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
|
||||
Reference in New Issue
Block a user