mongodb: ansible-lint fixes

This commit is contained in:
Timo Makinen 2022-10-30 15:48:34 +00:00
parent 75d8555e6c
commit 5907d1cef2
2 changed files with 20 additions and 18 deletions

View file

@ -1,6 +1,5 @@
---
- name: restart mongod
- name: Restart mongod
ansible.builtin.service:
name: mongod
state: restarted

View file

@ -1,11 +1,10 @@
---
- name: create group
- name: Create group
ansible.builtin.group:
name: mongod
gid: 1006
- name: create user
- name: Create user
ansible.builtin.user:
name: mongod
comment: Service MongoDB
@ -15,7 +14,7 @@
shell: /sbin/nologin
uid: 1006
- name: enable repository
- name: Enable repository
ansible.builtin.yum_repository:
name: mongodb
baseurl: https://repo.mongodb.org/yum/redhat/8/mongodb-org/5.0/x86_64
@ -24,7 +23,7 @@
gpgkey: https://www.mongodb.org/static/pgp/server-5.0.asc
enabled: true
- name: install packages
- name: Install packages
ansible.builtin.package:
name: "{{ item }}"
state: installed
@ -32,12 +31,12 @@
- mongodb-org-server
- mongodb-org-shell
- name: set selinux file contexts on data directory
- name: Set SELinux file contexts on data directory
community.general.sefcontext:
path: "/export/mongodb(/.*)?"
setype: mongod_var_lib_t
- name: create data directory
- name: Create data directory
ansible.builtin.file:
path: /export/mongodb
state: directory
@ -46,7 +45,7 @@
group: mongod
setype: _default
- name: link data directory
- name: Link data directory
ansible.builtin.file:
path: /srv/mongodb
src: /export/mongodb
@ -55,7 +54,7 @@
state: link
follow: false
- name: generate combined certificate/private key file contents
- name: Generate combined certificate/private key file contents
ansible.builtin.command:
argv:
- /bin/cat
@ -64,7 +63,7 @@
changed_when: false
register: mongodb_cert_key
- name: create combined certificate/private key file
- name: Create combined certificate/private key file
ansible.builtin.copy:
dest: "{{ tls_private }}/mongodb.pem"
content: "{{ mongodb_cert_key.stdout }}"
@ -73,7 +72,7 @@
group: mongod
notify: restart mongod
- name: configure logrotate
- name: Configure logrotate
ansible.builtin.copy:
dest: /etc/logrotate.d/mongod
src: mongod.logrotate
@ -81,7 +80,7 @@
owner: root
group: "{{ ansible_wheel }}"
- name: configure startup options
- name: Configure startup options
ansible.builtin.copy:
dest: /etc/sysconfig/mongod
content: |
@ -91,7 +90,7 @@
group: "{{ ansible_wheel }}"
notify: restart mongod
- name: create configuration
- name: Create configuration
ansible.builtin.template:
dest: /etc/mongod.conf
src: mongod.conf.j2
@ -100,14 +99,18 @@
group: "{{ ansible_wheel }}"
notify: restart mongod
- name: enable service
- name: Enable service
ansible.builtin.service:
name: mongod
state: started
enabled: true
- name: create mongo alias cmd for root
- name: Create mongo alias cmd for root
ansible.builtin.lineinfile:
path: /root/.bashrc
line: alias mongo='mongo --tlsCertificateKeyFile {{ tls_private }}/mongodb.pem --tlsCAFile {{ tls_certs }}/ca.crt --tls mongodb://{{ inventory_hostname }}/'
line: >
alias mongo='mongo
--tlsCertificateKeyFile {{ tls_private }}/mongodb.pem
--tlsCAFile {{ tls_certs }}/ca.crt
--tls mongodb://{{ inventory_hostname }}/'
regexp: ^alias mongo=.*