Created
June 8, 2015 16:40
-
-
Save anonymous/723d01575590f838eb39 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Location: /srv/salt/raidarray/ | |
## notice namespacing at top-level of each block, followed by the module.function | |
raid-create-array: | |
cmd.script: | |
- source: salt://raidarray/create_raid.sh | |
- cwd: / | |
- user: root | |
# here I am calling the pkg module and installed function but it requires first that cmd module ran previously on namespaced | |
# 'raid-create-array' (above) | |
mongodb-installed: | |
pkg.installed: | |
- require: | |
- cmd: raid-create-array | |
- name: mongodb | |
- sources: | |
- mongodb-org-server: salt://mongodb/mongodb-org-server-3.0.3-1.amzn1.x86_64.rpm | |
- mongodb-org-shell: salt://mongodb/mongodb-org-shell-3.0.3-1.amzn1.x86_64.rpm | |
# here I call the mount module with mounted function. Again require is used but it says make sure the pkd module ran successfully | |
# using the namespaced item 'mongodb-installed' (above) | |
raid-mount: | |
mount.mounted: | |
- require: | |
- pkg: mongodb-installed | |
- name: /mnt/md127 | |
- device: /dev/md127 | |
- fstype: ext4 | |
- dump: 0 | |
- pass_num: 2 | |
- persist: True | |
- mkmnt: True | |
- opts: defaults,nofail | |
- user: root | |
# continuing with trend of require, this time require makes sure previous namespaced item "raid-mount" ran using the "mount" | |
# module successfully | |
raid-mongo-datastore: | |
file.directory: | |
- require: | |
- mount: raid-mount | |
- name: /mnt/md127/mongo | |
- user: {{ pillar['raidarray']['usr'] }} | |
- group: {{ pillar['raidarray']['grp'] }} | |
- mode: 755 | |
- makedirs: True | |
- recurse: | |
- user | |
- group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Location /srv/salt/orchestration-create/ | |
## this step calls two SLS fils: setup.sls, and raidarray/init.sls | |
mongodb-server-setup: | |
salt.state: | |
- tgt: {{ pillar['minion'] }} | |
- sls: | |
- setup | |
- raidarray | |
# more ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Location /etc/salt/master.d/ | |
# I am using Reactor with Salt-Cloud on AWS so this part may not pertain, but after my | |
# EC2 instance is created and bootstrapped as minion it emits "created" event which is caught here | |
reactor: | |
- salt/cloud/*/created: | |
- /srv/reactor/server-created.sls | |
- salt/cloud/*/destroyed: | |
- /srv/reactor/server-removed.sls |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Location /srv/reactor/ | |
# here I parse through my targets emitting the "created" reactor event. | |
# For this example the server is named "mongodb-server-1" and would call the | |
# associated orchestration file "orchestration-create.mongodb-server | |
{% if data['name'].startswith("mongodb-server") %} | |
create-mongodb-server: | |
runner.state.orchestrate: | |
- mods: orchestration-create.mongodb-server | |
- pillar: | |
minion: {{ data['name'] }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment