Initial commit
This commit is contained in:
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