Skip to content

Instantly share code, notes, and snippets.

@justlooks
Last active December 26, 2015 09:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justlooks/7132325 to your computer and use it in GitHub Desktop.
Save justlooks/7132325 to your computer and use it in GitHub Desktop.
CM3:
----------
State: - pkgrepo
Name: mycluster
Function: managed
Result: True
Comment: Package repo mycluster already configured
Changes:
----------
State: - pkg
Name: zkpkgs
Function: installed
Result: True
Comment: All specified packages are already installed.
Changes:
----------
State: - file
Name: /etc/zookeeper/conf/zoo.cfg
Function: managed
Result: True
Comment: File /etc/zookeeper/conf/zoo.cfg is in the correct state
Changes:
mycluster:
pkgrepo.managed:
- humanname: chuanghe local cluster repo cdh4.3
- name: mycluster
- baseurl: http://192.168.142.128/cloudera-cdh4/
- gpgcheck: 0
zkpkgs:
pkg.installed:
- skip_verify: False
- pkgs:
- zookeeper
- zookeeper-server
- require:
- pkgrepo: mycluster
/etc/zookeeper/conf/zoo.cfg:
file.managed:
- source: salt://zookeeper/zoo.cfg
- template: jinja
- require:
- pkg: zkpkgs
- defaults:
maxcliconns: {{pillar['maxcliconns']}}
ticktime: {{pillar['ticktime']}}
initlimit: {{pillar['initlimit']}}
synclimit: {{pillar['synclimit']}}
datadir: {{pillar['datadir']}}
clientport: {{pillar['clientport']}}
{% if not salt['file.file_exists'](pillar['datadir']~'/myid') %}
zkinit:
cmd.run:
- name: service zookeeper-server init --myid {% for i in pillar['cluster'] %}{% if i[2:] == grains['ip_interfaces']['eth0'][0] %}{{i[0:1]}}{% endif %}{% endfor %}
- require:
- file: /etc/zookeeper/conf/zoo.cfg
{% endif %}
zookeeper-server:
service:
- running
- require:
- file: {{pillar['datadir']~'/myid'}} # it cause problem because no such state exist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment