|
|
|
|
|
|
|
|
- user: mongodb |
|
|
- user: mongodb |
|
|
- require: |
|
|
- require: |
|
|
- pkg: mongodb_packages |
|
|
- pkg: mongodb_packages |
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
- watch_in: |
|
|
- watch_in: |
|
|
- service: mongodb_service |
|
|
- service: mongodb_service |
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file.directory: |
|
|
file.directory: |
|
|
- makedirs: true |
|
|
- makedirs: true |
|
|
|
|
|
|
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
|
|
|
|
|
|
mongodb_service: |
|
|
mongodb_service: |
|
|
service.running: |
|
|
service.running: |
|
|
- name: {{ server.service }} |
|
|
- name: {{ server.service }} |
|
|
- enable: true |
|
|
- enable: true |
|
|
|
|
|
{%- if grains.get('noservices') %} |
|
|
|
|
|
- onlyif: /bin/false |
|
|
|
|
|
{%- endif %} |
|
|
- require: |
|
|
- require: |
|
|
- file: {{ server.lock_dir }} |
|
|
- file: {{ server.lock_dir }} |
|
|
- pkg: mongodb_packages |
|
|
- pkg: mongodb_packages |
|
|
- watch: |
|
|
- watch: |
|
|
- file: /etc/mongodb.conf |
|
|
- file: /etc/mongodb.conf |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
|
|
|
{%- if server.members is not defined or server.master == pillar.linux.system.name %} |
|
|
{%- if server.members is not defined or server.master == pillar.linux.system.name %} |
|
|
{# We are not a cluster or we are master #} |
|
|
{# We are not a cluster or we are master #} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- mode: 600 |
|
|
- mode: 600 |
|
|
- user: root |
|
|
- user: root |
|
|
|
|
|
|
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
|
|
|
|
|
|
mongodb_change_root_password: |
|
|
mongodb_change_root_password: |
|
|
cmd.run: |
|
|
cmd.run: |
|
|
- name: 'mongo localhost:27017/admin /var/tmp/mongodb_user.js && touch {{ server.lock_dir }}/mongodb_password_changed' |
|
|
- name: 'mongo localhost:27017/admin /var/tmp/mongodb_user.js && touch {{ server.lock_dir }}/mongodb_password_changed' |
|
|
|
|
|
{%- if grains.get('noservices') %} |
|
|
|
|
|
- onlyif: /bin/false |
|
|
|
|
|
{%- endif %} |
|
|
- require: |
|
|
- require: |
|
|
- file: /var/tmp/mongodb_user.js |
|
|
- file: /var/tmp/mongodb_user.js |
|
|
- service: mongodb_service |
|
|
- service: mongodb_service |
|
|
- creates: {{ server.lock_dir }}/mongodb_password_changed |
|
|
- creates: {{ server.lock_dir }}/mongodb_password_changed |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
|
|
|
{%- for database_name, database in server.get('database', {}).iteritems() %} |
|
|
{%- for database_name, database in server.get('database', {}).iteritems() %} |
|
|
|
|
|
|
|
|
/var/tmp/mongodb_user_{{ database_name }}.js: |
|
|
/var/tmp/mongodb_user_{{ database_name }}.js: |
|
|
|
|
|
|
|
|
- defaults: |
|
|
- defaults: |
|
|
database_name: {{ database_name }} |
|
|
database_name: {{ database_name }} |
|
|
|
|
|
|
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
|
|
|
|
|
|
mongodb_{{ database_name }}_fix_role: |
|
|
mongodb_{{ database_name }}_fix_role: |
|
|
cmd.run: |
|
|
cmd.run: |
|
|
- name: 'mongo localhost:27017/admin -u admin -p {{ server.admin.password }} /var/tmp/mongodb_user_{{ database_name }}.js && touch {{ server.lock_dir }}/mongodb_user_{{ database_name }}_created' |
|
|
- name: 'mongo localhost:27017/admin -u admin -p {{ server.admin.password }} /var/tmp/mongodb_user_{{ database_name }}.js && touch {{ server.lock_dir }}/mongodb_user_{{ database_name }}_created' |
|
|
|
|
|
{%- if grains.get('noservices') %} |
|
|
|
|
|
- onlyif: /bin/false |
|
|
|
|
|
{%- endif %} |
|
|
- require: |
|
|
- require: |
|
|
- file: /var/tmp/mongodb_user_{{ database_name }}.js |
|
|
- file: /var/tmp/mongodb_user_{{ database_name }}.js |
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
- service: mongodb_service |
|
|
- service: mongodb_service |
|
|
{%- endif%} |
|
|
|
|
|
- creates: {{ server.lock_dir }}/mongodb_user_{{ database_name }}_created |
|
|
- creates: {{ server.lock_dir }}/mongodb_user_{{ database_name }}_created |
|
|
{%- if server.members is defined %} |
|
|
{%- if server.members is defined %} |
|
|
require: |
|
|
require: |
|
|
- cmd: mongodb_setup_cluster |
|
|
- cmd: mongodb_setup_cluster |
|
|
{%- endif %} |
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
{%- endif %} |
|
|
|
|
|
|
|
|
|
|
|
{%- endfor %} |
|
|
{%- endfor %} |
|
|
|
|
|
|
|
|
{%- if server.members is defined %} |
|
|
{%- if server.members is defined %} |
|
|
|
|
|
|
|
|
- name: 'mongo localhost:27017/admin /var/tmp/mongodb_cluster.js && mongo localhost:27017/admin --quiet --eval "rs.conf()" | grep object -q' |
|
|
- name: 'mongo localhost:27017/admin /var/tmp/mongodb_cluster.js && mongo localhost:27017/admin --quiet --eval "rs.conf()" | grep object -q' |
|
|
- unless: 'mongo localhost:27017/admin -u admin -p {{ server.admin.password }} --quiet --eval "rs.conf()" | grep object -q' |
|
|
- unless: 'mongo localhost:27017/admin -u admin -p {{ server.admin.password }} --quiet --eval "rs.conf()" | grep object -q' |
|
|
- require: |
|
|
- require: |
|
|
{%- if not grains.get('noservices', False) %} |
|
|
|
|
|
- service: mongodb_service |
|
|
- service: mongodb_service |
|
|
{%- endif %} |
|
|
|
|
|
- file: /var/tmp/mongodb_cluster.js |
|
|
- file: /var/tmp/mongodb_cluster.js |
|
|
- require_in: |
|
|
- require_in: |
|
|
- cmd: mongodb_change_root_password |
|
|
- cmd: mongodb_change_root_password |