Fix for linting warnings

This commit is contained in:
Sergei Antipov 2019-05-21 15:42:02 -04:00
parent 3cfe431492
commit 02495dece3
No known key found for this signature in database
GPG Key ID: B167B87787407B3A
9 changed files with 89 additions and 82 deletions

View File

@ -2,7 +2,8 @@
mongodb_package: mongodb-org
mongodb_package_state: present
mongodb_version: "3.6"
mongodb_package_version: "4.0.9"
mongodb_version: "4.0"
mongodb_apt_keyserver: keyserver.ubuntu.com
mongodb_apt_key_id:
"3.4": "0C49F3730359A14518585931BC711F9BA15703C6"

View File

@ -1,5 +1,10 @@
---
- name: reload systemd
systemd:
daemon_reload: yes
when: ansible_service_mgr == "systemd" and mongodb_manage_service
- name: mongodb reload
service: name={{ mongodb_daemon_name }} state=reloaded
when: mongodb_manage_service
@ -12,9 +17,5 @@
service: name=mongodb-mms-monitoring-agent state=restarted
when: mongodb_manage_service
- name: reload systemd
shell: systemctl daemon-reload
when: mongodb_is_systemd and mongodb_manage_service
- name: restart sysfsutils
service: name=sysfsutils state=restarted

View File

@ -9,16 +9,6 @@
- name: wait MongoDB port is listening
wait_for: host=127.0.0.1 port="{{ mongodb_net_port }}" delay=5 state=started
- name: get pid of mongodb for non daemon mode
shell: "pidof mongod"
register: pidof_mongod
when: mongodb_manage_service == false
ignore_errors: yes
- name: start mongodb daemon
shell: "LC_ALL=C /usr/bin/mongod --config /etc/mongod.conf --fork"
when: mongodb_manage_service == false and pidof_mongod.rc == 1
- name: create administrative user siteUserAdmin
mongodb_user:
database: admin

View File

@ -7,22 +7,31 @@
owner: "{{ mongodb_user }}"
group: "root"
mode: 0600
when: mongodb_replication_replset and mongodb_replication_replset != ''
when: mongodb_replication_replset
- name: set mongodb gid
group: name=mongodb gid={{ mongodb_gid }} state=present
group:
name: "{{ mongodb_user }}"
gid: "{{ mongodb_gid }}"
state: present
when: mongodb_gid
- name: set mongodb uid
user: name=mongodb uid={{ mongodb_uid }} group=mongodb state=present
when: mongodb_uid
- name: reset mongodb folder and subfolders with new uid
file: path={{ mongodb_storage_dbpath }} owner=mongodb group=mongodb follow=yes recurse=yes state=directory
user:
name: "{{ mongodb_user }}"
uid: "{{ mongodb_uid }}"
group: "{{ mongodb_user }}"
state: present
when: mongodb_uid
- name: Create log dir if missing
file: state=directory recurse=yes dest={{ mongodb_systemlog_path|dirname }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
file:
state: directory
recurse: true
dest: "{{ mongodb_systemlog_path|dirname }}"
owner: "{{ mongodb_user }}"
group: "{{ mongodb_user }}"
mode: 0755
when: mongodb_systemlog_destination == "file"
- name: Check than logfile exists
@ -31,7 +40,12 @@
when: mongodb_systemlog_destination == "file"
- name: Create log if missing
file: state=touch dest={{ mongodb_systemlog_path }} owner={{ mongodb_user }} group={{mongodb_user}} mode=0755
file:
state: touch
dest: "{{ mongodb_systemlog_path }}"
owner: "{{ mongodb_user }}"
group: "{{ mongodb_user }}"
mode: 0755
when: ( mongodb_systemlog_destination == "file"
and logfile_stat is defined
and not logfile_stat.stat.exists )
@ -41,11 +55,19 @@
path: "{{ mongodb_storage_dbpath }}"
state: directory
owner: "{{ mongodb_user }}"
group: "{{ mongodb_user }}"
setype: 'mongod_var_lib_t'
recurse: yes
recurse: true
follow: true
- name: Configure mongodb
template: src=mongod.conf.j2 dest=/etc/mongod.conf backup=yes owner=root group=root mode=0644
template:
src: mongod.conf.j2
dest: /etc/mongod.conf
backup: true
owner: root
group: root
mode: 0644
register: config_result
- name: mongodb restart

View File

@ -13,15 +13,18 @@
- name: Install MongoDB package
yum:
name:
- "{{ mongodb_package }}"
- numactl
state: present
name: "{{ mongodb_package }}"
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_package_version | default(omit) }}"
- name: Install numactl package
yum:
name: numactl
- name: Install PyMongo package
yum:
name: python-pymongo
state: latest
state: present
when: not mongodb_pymongo_from_pip
- name: Install PIP

View File

@ -8,14 +8,13 @@
- name: Establish some role-related facts
set_fact:
mongodb_is_systemd: "{{ sbin_init.stat.islnk is defined and sbin_init.stat.islnk }}"
mongodb_major_version: "{{ mongodb_version[0:3] }}"
- name: Disable transparent huge pages on systemd systems
include_tasks: disable_transparent_hugepages.yml
when:
- mongodb_disable_transparent_hugepages
- mongodb_is_systemd
- ansible_service_mgr == "systemd"
- name: Add APT key
apt_key:
@ -53,32 +52,33 @@
when: mongodb_package == 'mongodb-org'
- name: Install MongoDB package
apt:
name:
- "{{mongodb_package}}"
- numactl
state: "{{ mongodb_package_state }}"
update_cache: yes
apt:
name: "{{ mongodb_package }}"
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_package_version | default(omit) }}"
update_cache: true
- name: Install numactl package
apt:
name: numactl
state: present
update_cache: true
- name: Add systemd configuration if present
copy: src=mongodb.service dest=/lib/systemd/system/mongodb.service owner=root group=root mode=0644
when: mongodb_is_systemd
when: ansible_service_mgr == "systemd"
- name: Add symlink for systemd
file: src=/lib/systemd/system/mongodb.service dest=/etc/systemd/system/multi-user.target.wants/mongodb.service state=link
when: mongodb_is_systemd
notify: reload systemd
- name: reload systemd
shell: systemctl daemon-reload
when: mongodb_is_systemd and mongodb_manage_service
when: ansible_service_mgr == "systemd"
- block:
- meta: flush_handlers
when: mongodb_is_systemd
- meta: flush_handlers
when: ansible_service_mgr == "systemd"
- name: Install PyMongo package
apt: pkg=python-pymongo state=latest
apt:
name: python-pymongo
when: not mongodb_pymongo_from_pip
- name: Install PIP

View File

@ -19,16 +19,18 @@
- name: Install MongoDB package
yum:
name: "{{ item }}"
state: present
with_items:
- "{{ mongodb_package }}"
- numactl
name: "{{ mongodb_package }}"
state: "{{ mongodb_package_version is defined | ternary('present', 'latest') }}"
version: "{{ mongodb_package_version | default(omit) }}"
- name: Install numactl package
yum:
name: numactl
- name: Install PyMongo package
yum:
name: python-pymongo
state: latest
state: present
when: not mongodb_pymongo_from_pip
- name: Install PIP

View File

@ -21,14 +21,13 @@
- name: Include replication and auth configuration
include: replication_init_auth.yml
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
tags: [mongodb]
- name: Include replication configuration
include: replication.yml
when: mongodb_replication_replset and mongodb_replication_replset != ''
when: mongodb_replication_replset
tags: [mongodb]
- name: Check where admin user already exists
@ -40,16 +39,14 @@
check_mode: no
ignore_errors: true
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '') )
and not mongodb_replication_replset )
no_log: true
tags: [mongodb]
- name: Include authorization configuration
include: auth_initialization.yml
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '')
and not mongodb_replication_replset
and mongodb_user_admin_check.rc != 0 )
tags: [mongodb]
@ -67,7 +64,6 @@
with_items:
- "{{ mongodb_users | default([]) }}"
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
no_log: true
@ -86,8 +82,7 @@
with_items:
- "{{ mongodb_users | default([]) }}"
when: ( mongodb_security_authorization == 'enabled'
and (not mongodb_replication_replset
or mongodb_replication_replset == '') )
and not mongodb_replication_replset )
no_log: true
tags: [mongodb]
@ -107,7 +102,6 @@
with_items:
- "{{ mongodb_oplog_users | default([]) }}"
when: ( mongodb_replication_replset
and mongodb_replication_replset != ''
and mongodb_security_authorization == 'enabled'
and mongodb_master is defined and mongodb_master )
no_log: false
@ -115,5 +109,5 @@
- name: Include MMS Agent configuration
include: mms-agent.yml
when: mongodb_mms_api_key != ""
when: mongodb_mms_api_key
tags: [mongodb]

View File

@ -1,28 +1,22 @@
---
- name: Download MMS Agent (Debian)
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.deb
register: mongodb_mms_agent_loaded
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install MMS agent (Debian)
apt:
deb: "{{mongodb_storage_dbpath}}/mms-agent.deb"
when: mongodb_mms_agent_loaded.changed #and (ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu')
- name: Download MMS Agent (RHEL)
get_url: url={{mongodb_mms_agent_pkg}} dest={{mongodb_storage_dbpath}}/mms-agent.rpm
register: mongodb_mms_agent_loaded
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
deb: "{{ mongodb_mms_agent_pkg }}"
when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu'
- name: Install MMS agent (RHEL)
yum:
name: "{{mongodb_storage_dbpath}}/mms-agent.rpm"
name: "{{ mongodb_mms_agent_pkg }}"
state: present
when: mongodb_mms_agent_loaded.changed and (ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat')
when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat'
- name: Configure the MMS agent pt. 1
file: state=directory path=/etc/mongodb-mms owner={{mongodb_user}} group={{mongodb_user}} mode=0755
file:
state: directory
path: /etc/mongodb-mms
owner: "{{ mongodb_user }}"
group: "{{ mongodb_user }}"
mode: 0755
- name: Configure the MMS agent pt. 2
template: src=monitoring-agent.config.j2 dest=/etc/mongodb-mms/monitoring-agent.config