fix ansible guideine errors
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2019-01-12 14:40:16 +01:00
parent 07c7188500
commit a3880a4698
5 changed files with 112 additions and 107 deletions

View File

@ -1,3 +1,4 @@
# Standards: 0.1
--- ---
galaxy_info: galaxy_info:
author: xoxys author: xoxys
@ -5,9 +6,9 @@ galaxy_info:
license: MIT license: MIT
min_ansible_version: 2.4 min_ansible_version: 2.4
platforms: platforms:
- name: EL - name: EL
versions: versions:
- 7 - 7
galaxy_tags: galaxy_tags:
- db - db
- mongodb - mongodb

View File

@ -1,25 +1,26 @@
--- ---
- block: - block:
- name: Backup current config file - name: Backup current config file
copy: copy:
src: /etc/mongod.conf src: /etc/mongod.conf
dest: /etc/mongod.conf.bak dest: /etc/mongod.conf.bak
remote_src: True remote_src: True
changed_when: False changed_when: False
- name: Deploy config file without auth - name: Deploy config file without auth
template: template:
src: etc/mongod_init.conf.j2 src: etc/mongod_init.conf.j2
dest: /etc/mongod.conf dest: /etc/mongod.conf
mode: 0644 mode: 0644
changed_when: False changed_when: False
- name: Restart service - name: Restart service to disable auth
service: service:
name: mongod name: mongod
state: restarted state: restarted
changed_when: False changed_when: False
become: True become: True
become_user: root
- name: Create admin user - name: Create admin user
mongodb_user: mongodb_user:
@ -30,16 +31,17 @@
state: present state: present
- block: - block:
- name: Restore config file - name: Restore config file
copy: copy:
src: /etc/mongod.conf.bak src: /etc/mongod.conf.bak
dest: /etc/mongod.conf dest: /etc/mongod.conf
remote_src: True remote_src: True
changed_when: False changed_when: False
- name: Restart service - name: Restart service to re-enable auth
service: service:
name: mongod name: mongod
state: restarted state: restarted
changed_when: False changed_when: False
become: True become: True
become_user: root

View File

@ -1,16 +1,16 @@
--- ---
- block: - block:
- name: Deploy configuration file - name: Deploy configuration file
template: template:
src: etc/mongod.conf.j2 src: etc/mongod.conf.j2
dest: /etc/mongod.conf dest: /etc/mongod.conf
mode: 0644 mode: 0644
notify: __mongod_restart notify: __mongod_restart
- name: Make sure mongodb is up and running - name: Make sure mongodb is up and running
service: service:
name: mongod name: mongod
state: started state: started
enabled: yes enabled: yes
become: True become: True
become_user: root become_user: root

View File

@ -1,56 +1,57 @@
--- ---
- block: - block:
- name: Add repository for major version '{{ mongodb_version }}' - name: Add repository for major version '{{ mongodb_version }}'
yum_repository: yum_repository:
name: mongodb name: mongodb
description: MongoDB Repository description: MongoDB Repository
baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/" baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/"
gpgcheck: yes gpgcheck: yes
enabled: yes enabled: yes
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc" gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
- name: Install packages - name: Install packages
package: package:
name: "{{ item }}" name: "{{ item }}"
state: present state: present
with_items: with_items:
- mongodb-org - mongodb-org
- python2-pip - python2-pip
- name: Create group '{{ mongodb_system_group }}' - name: Create group '{{ mongodb_system_group }}'
group: group:
name: "{{ mongodb_system_group }}" name: "{{ mongodb_system_group }}"
gid: "{{ mongodb_system_gid | default(omit) }}" gid: "{{ mongodb_system_gid | default(omit) }}"
state: present state: present
- name: Create user '{{ mongodb_system_user }}' - name: Create user '{{ mongodb_system_user }}'
user: user:
name: "{{ mongodb_system_user }}" name: "{{ mongodb_system_user }}"
uid: "{{ mongodb_system_uid | default(omit) }}" uid: "{{ mongodb_system_uid | default(omit) }}"
group: "{{ mongodb_system_group }}" group: "{{ mongodb_system_group }}"
- name: Create db storage dir '{{ mongodb_storage_dbpath }}' - name: Create db storage dir '{{ mongodb_storage_dbpath }}'
file: file:
path: "{{ mongodb_storage_dbpath }}" path: "{{ mongodb_storage_dbpath }}"
owner: "{{ mongodb_system_user }}" owner: "{{ mongodb_system_user }}"
group: "{{ mongodb_system_group }}" group: "{{ mongodb_system_group }}"
selevel: s0 selevel: s0
serole : object_r serole : object_r
setype: mongod_var_lib_t setype: mongod_var_lib_t
seuser: system_u seuser: system_u
state: directory state: directory
notify: __mongod_restart notify: __mongod_restart
- name: Create log dir '{{ mongodb_systemlog_path | dirname }}' - name: Create log dir '{{ mongodb_systemlog_path | dirname }}'
file: file:
path: "{{ mongodb_systemlog_path | dirname }}" path: "{{ mongodb_systemlog_path | dirname }}"
owner: "{{ mongodb_system_user }}" owner: "{{ mongodb_system_user }}"
group: "{{ mongodb_system_group }}" group: "{{ mongodb_system_group }}"
recurse: yes recurse: yes
state: directory state: directory
when: mongodb_systemlog_destination == 'file' when: mongodb_systemlog_destination == 'file'
notify: __mongod_restart notify: __mongod_restart
become: True become: True
become_user: root
- name: Install pymongo as ansible dependency - name: Install pymongo as ansible dependency
pip: pip:

View File

@ -1,26 +1,27 @@
--- ---
- block: - block:
- name: Create volume group '{{ mongodb_lvm_vg }}' - name: Create volume group '{{ mongodb_lvm_vg }}'
lvg: lvg:
vg: "{{ mongodb_lvm_vg }}" vg: "{{ mongodb_lvm_vg }}"
pvs: "{{ mongodb_lvm_pvs|join(',') }}" pvs: "{{ mongodb_lvm_pvs|join(',') }}"
- name: Create logical volume '{{ mongodb_lvm_lv }}' - name: Create logical volume '{{ mongodb_lvm_lv }}'
lvol: lvol:
vg: "{{ mongodb_lvm_vg }}" vg: "{{ mongodb_lvm_vg }}"
lv: "{{ mongodb_lvm_lv }}" lv: "{{ mongodb_lvm_lv }}"
size: "{{ mongodb_lvm_size }}" size: "{{ mongodb_lvm_size }}"
- name: Create filesystem for '/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}' - name: Create filesystem for '/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}'
filesystem: filesystem:
fstype: "{{ mongodb_lvm_fstype }}" fstype: "{{ mongodb_lvm_fstype }}"
dev: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}" dev: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
resizefs: True resizefs: True
- name: Mount volume to '{{ mongodb_storage_dbpath }}' - name: Mount volume to '{{ mongodb_storage_dbpath }}'
mount: mount:
path: "{{ mongodb_storage_dbpath }}" path: "{{ mongodb_storage_dbpath }}"
src: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}" src: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
fstype: "{{ mongodb_lvm_fstype }}" fstype: "{{ mongodb_lvm_fstype }}"
state: mounted state: mounted
become: True become: True
become_user: root