1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #
- # mongodb
- #
- mongodb-repo:
- pkgrepo.managed:
- - humanname: MongoDB Repo
- - file: /etc/apt/sources.list.d/mongodb-org.list
- - key_url: https://www.mongodb.org/static/pgp/server-{{ mongodb_version }}.asc
- {% if mongodb_version == '4.2' %}
- - name: deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main
- {% elif mongodb_version == '4.4' %}
- - name: deb http://repo.mongodb.org/apt/debian buster/mongodb-org/4.4 main
- {% elif mongodb_version == '5.0' %}
- - name: deb http://repo.mongodb.org/apt/debian {{ grains.oscodename }}/mongodb-org/5.0 main
- {% endif %}
- mongodb:
- pkg.installed:
- - pkgs:
- - mongodb-org
- - python3-pymongo
- service.running:
- - name: mongod
- - enable: True
- - require:
- - pkg: mongodb
- - watch:
- - file: /etc/mongod.conf
- # Create mongodb admin user
- mongoadmin:
- mongodb_user.present:
- - name: {{ mongodb_admin_username }}
- - passwd: {{ mongodb_admin_password }}
- - database: admin
- - roles: {{ mongodb_admin_roles }}
- - user: {{ mongodb_admin_username }}
- - password: {{ mongodb_admin_password }}
- # Install mongod config, cronjob, backup script and corresponding config file
- /etc/mongod.conf:
- file.managed:
- - source: salt://mongodb/mongod.conf
- - require:
- - mongodb_user: mongoadmin
- /etc/cron.d/mongodb_backup:
- file.managed:
- - source: salt://mongodb/mongodb_backup.cron
- /usr/local/sbin/mongodb_backup:
- file.managed:
- - source: salt://mongodb/mongodb_backup
- - mode: 755
- /etc/mongodb_backup.conf:
- file.managed:
- - source: salt://mongodb/mongodb_backup.conf
- - mode: 600
- - user: root
- - group: root
|