This commit is contained in:
parent
07c7188500
commit
a3880a4698
@ -1,3 +1,4 @@
|
||||
# Standards: 0.1
|
||||
---
|
||||
galaxy_info:
|
||||
author: xoxys
|
||||
@ -5,9 +6,9 @@ galaxy_info:
|
||||
license: MIT
|
||||
min_ansible_version: 2.4
|
||||
platforms:
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
- name: EL
|
||||
versions:
|
||||
- 7
|
||||
galaxy_tags:
|
||||
- db
|
||||
- mongodb
|
||||
|
@ -1,25 +1,26 @@
|
||||
---
|
||||
- block:
|
||||
- name: Backup current config file
|
||||
copy:
|
||||
src: /etc/mongod.conf
|
||||
dest: /etc/mongod.conf.bak
|
||||
remote_src: True
|
||||
changed_when: False
|
||||
- name: Backup current config file
|
||||
copy:
|
||||
src: /etc/mongod.conf
|
||||
dest: /etc/mongod.conf.bak
|
||||
remote_src: True
|
||||
changed_when: False
|
||||
|
||||
- name: Deploy config file without auth
|
||||
template:
|
||||
src: etc/mongod_init.conf.j2
|
||||
dest: /etc/mongod.conf
|
||||
mode: 0644
|
||||
changed_when: False
|
||||
- name: Deploy config file without auth
|
||||
template:
|
||||
src: etc/mongod_init.conf.j2
|
||||
dest: /etc/mongod.conf
|
||||
mode: 0644
|
||||
changed_when: False
|
||||
|
||||
- name: Restart service
|
||||
service:
|
||||
name: mongod
|
||||
state: restarted
|
||||
changed_when: False
|
||||
- name: Restart service to disable auth
|
||||
service:
|
||||
name: mongod
|
||||
state: restarted
|
||||
changed_when: False
|
||||
become: True
|
||||
become_user: root
|
||||
|
||||
- name: Create admin user
|
||||
mongodb_user:
|
||||
@ -30,16 +31,17 @@
|
||||
state: present
|
||||
|
||||
- block:
|
||||
- name: Restore config file
|
||||
copy:
|
||||
src: /etc/mongod.conf.bak
|
||||
dest: /etc/mongod.conf
|
||||
remote_src: True
|
||||
changed_when: False
|
||||
- name: Restore config file
|
||||
copy:
|
||||
src: /etc/mongod.conf.bak
|
||||
dest: /etc/mongod.conf
|
||||
remote_src: True
|
||||
changed_when: False
|
||||
|
||||
- name: Restart service
|
||||
service:
|
||||
name: mongod
|
||||
state: restarted
|
||||
changed_when: False
|
||||
- name: Restart service to re-enable auth
|
||||
service:
|
||||
name: mongod
|
||||
state: restarted
|
||||
changed_when: False
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -1,16 +1,16 @@
|
||||
---
|
||||
- block:
|
||||
- name: Deploy configuration file
|
||||
template:
|
||||
src: etc/mongod.conf.j2
|
||||
dest: /etc/mongod.conf
|
||||
mode: 0644
|
||||
notify: __mongod_restart
|
||||
- name: Deploy configuration file
|
||||
template:
|
||||
src: etc/mongod.conf.j2
|
||||
dest: /etc/mongod.conf
|
||||
mode: 0644
|
||||
notify: __mongod_restart
|
||||
|
||||
- name: Make sure mongodb is up and running
|
||||
service:
|
||||
name: mongod
|
||||
state: started
|
||||
enabled: yes
|
||||
- name: Make sure mongodb is up and running
|
||||
service:
|
||||
name: mongod
|
||||
state: started
|
||||
enabled: yes
|
||||
become: True
|
||||
become_user: root
|
||||
|
@ -1,56 +1,57 @@
|
||||
---
|
||||
- block:
|
||||
- name: Add repository for major version '{{ mongodb_version }}'
|
||||
yum_repository:
|
||||
name: mongodb
|
||||
description: MongoDB Repository
|
||||
baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/"
|
||||
gpgcheck: yes
|
||||
enabled: yes
|
||||
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
|
||||
- name: Add repository for major version '{{ mongodb_version }}'
|
||||
yum_repository:
|
||||
name: mongodb
|
||||
description: MongoDB Repository
|
||||
baseurl: "https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/{{ mongodb_version }}/x86_64/"
|
||||
gpgcheck: yes
|
||||
enabled: yes
|
||||
gpgkey: "https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc"
|
||||
|
||||
- name: Install packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- mongodb-org
|
||||
- python2-pip
|
||||
- name: Install packages
|
||||
package:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
with_items:
|
||||
- mongodb-org
|
||||
- python2-pip
|
||||
|
||||
- name: Create group '{{ mongodb_system_group }}'
|
||||
group:
|
||||
name: "{{ mongodb_system_group }}"
|
||||
gid: "{{ mongodb_system_gid | default(omit) }}"
|
||||
state: present
|
||||
- name: Create group '{{ mongodb_system_group }}'
|
||||
group:
|
||||
name: "{{ mongodb_system_group }}"
|
||||
gid: "{{ mongodb_system_gid | default(omit) }}"
|
||||
state: present
|
||||
|
||||
- name: Create user '{{ mongodb_system_user }}'
|
||||
user:
|
||||
name: "{{ mongodb_system_user }}"
|
||||
uid: "{{ mongodb_system_uid | default(omit) }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
- name: Create user '{{ mongodb_system_user }}'
|
||||
user:
|
||||
name: "{{ mongodb_system_user }}"
|
||||
uid: "{{ mongodb_system_uid | default(omit) }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
|
||||
- name: Create db storage dir '{{ mongodb_storage_dbpath }}'
|
||||
file:
|
||||
path: "{{ mongodb_storage_dbpath }}"
|
||||
owner: "{{ mongodb_system_user }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
selevel: s0
|
||||
serole : object_r
|
||||
setype: mongod_var_lib_t
|
||||
seuser: system_u
|
||||
state: directory
|
||||
notify: __mongod_restart
|
||||
- name: Create db storage dir '{{ mongodb_storage_dbpath }}'
|
||||
file:
|
||||
path: "{{ mongodb_storage_dbpath }}"
|
||||
owner: "{{ mongodb_system_user }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
selevel: s0
|
||||
serole : object_r
|
||||
setype: mongod_var_lib_t
|
||||
seuser: system_u
|
||||
state: directory
|
||||
notify: __mongod_restart
|
||||
|
||||
- name: Create log dir '{{ mongodb_systemlog_path | dirname }}'
|
||||
file:
|
||||
path: "{{ mongodb_systemlog_path | dirname }}"
|
||||
owner: "{{ mongodb_system_user }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
when: mongodb_systemlog_destination == 'file'
|
||||
notify: __mongod_restart
|
||||
- name: Create log dir '{{ mongodb_systemlog_path | dirname }}'
|
||||
file:
|
||||
path: "{{ mongodb_systemlog_path | dirname }}"
|
||||
owner: "{{ mongodb_system_user }}"
|
||||
group: "{{ mongodb_system_group }}"
|
||||
recurse: yes
|
||||
state: directory
|
||||
when: mongodb_systemlog_destination == 'file'
|
||||
notify: __mongod_restart
|
||||
become: True
|
||||
become_user: root
|
||||
|
||||
- name: Install pymongo as ansible dependency
|
||||
pip:
|
||||
|
@ -1,26 +1,27 @@
|
||||
---
|
||||
- block:
|
||||
- name: Create volume group '{{ mongodb_lvm_vg }}'
|
||||
lvg:
|
||||
vg: "{{ mongodb_lvm_vg }}"
|
||||
pvs: "{{ mongodb_lvm_pvs|join(',') }}"
|
||||
- name: Create volume group '{{ mongodb_lvm_vg }}'
|
||||
lvg:
|
||||
vg: "{{ mongodb_lvm_vg }}"
|
||||
pvs: "{{ mongodb_lvm_pvs|join(',') }}"
|
||||
|
||||
- name: Create logical volume '{{ mongodb_lvm_lv }}'
|
||||
lvol:
|
||||
vg: "{{ mongodb_lvm_vg }}"
|
||||
lv: "{{ mongodb_lvm_lv }}"
|
||||
size: "{{ mongodb_lvm_size }}"
|
||||
- name: Create logical volume '{{ mongodb_lvm_lv }}'
|
||||
lvol:
|
||||
vg: "{{ mongodb_lvm_vg }}"
|
||||
lv: "{{ mongodb_lvm_lv }}"
|
||||
size: "{{ mongodb_lvm_size }}"
|
||||
|
||||
- name: Create filesystem for '/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}'
|
||||
filesystem:
|
||||
fstype: "{{ mongodb_lvm_fstype }}"
|
||||
dev: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
||||
resizefs: True
|
||||
- name: Create filesystem for '/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}'
|
||||
filesystem:
|
||||
fstype: "{{ mongodb_lvm_fstype }}"
|
||||
dev: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
||||
resizefs: True
|
||||
|
||||
- name: Mount volume to '{{ mongodb_storage_dbpath }}'
|
||||
mount:
|
||||
path: "{{ mongodb_storage_dbpath }}"
|
||||
src: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
||||
fstype: "{{ mongodb_lvm_fstype }}"
|
||||
state: mounted
|
||||
- name: Mount volume to '{{ mongodb_storage_dbpath }}'
|
||||
mount:
|
||||
path: "{{ mongodb_storage_dbpath }}"
|
||||
src: "/dev/mapper/{{ mongodb_lvm_vg }}-{{ mongodb_lvm_lv }}"
|
||||
fstype: "{{ mongodb_lvm_fstype }}"
|
||||
state: mounted
|
||||
become: True
|
||||
become_user: root
|
||||
|
Loading…
Reference in New Issue
Block a user