Skip to content

Instantly share code, notes, and snippets.

@tateeskew
Created November 25, 2013 18:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tateeskew/7645966 to your computer and use it in GitHub Desktop.
Save tateeskew/7645966 to your computer and use it in GitHub Desktop.
Example SLS and Top for issue: https://github.com/saltstack/salt/issues/7526
local:
Data failed to compile:
----------
Detected conflicting IDs, SLS IDs need to be globally unique.
The conflicting ID is "add-postgres-key" and is found in SLS "base:postgres-repo" and SLS "base:postgres-repo"
----------
Detected conflicting IDs, SLS IDs need to be globally unique.
The conflicting ID is "/etc/apt/sources.list.d/pgdg.list" and is found in SLS "base:postgres-repo" and SLS "base:postgres-repo"
----------
Detected conflicting IDs, SLS IDs need to be globally unique.
The conflicting ID is "update-postgres-apt" and is found in SLS "base:postgres-repo" and SLS "base:postgres-repo"
THIS FILE IS LOCATED AT: /srv/salt/dev/bamboo-base-image-pg93/init.sls
include:
- base: postgres-repo
# Base Packages for Bamboo Build Image
requisite_packages:
pkg.installed:
- names:
- memcached
- spamc
- libjpeg-dev
- libjpeg-progs
- gifsicle
- pngcrush
- imagemagick
- tidy
spamassassin_config:
file.managed:
- name: /etc/default/spamassassin
- source: salt://bamboo-base-image-pg93/etc/default/spamassassin
- require:
- pkg: spamassassin
spamassassin:
pkg:
- installed
- name: spamassassin
service:
- running
- enable: True
- reload: True
- watch:
- file: spamassassin_config
# Directories needed by Build
/opt/integration:
file.directory:
- mode: 777
- makedirs: True
# Node.js and modules
node-repo:
pkgrepo.managed:
- ppa: chris-lea/node.js
nodejs:
pkg.installed:
- require:
- pkgrepo: node-repo
grunt-cli:
npm.installed:
- require:
- pkg: nodejs
mocha:
npm.installed:
- require:
- pkg: nodejs
# Redis
add_redis_ppa:
cmd.run:
- name: "add-apt-repository ppa:chris-lea/redis-server; apt-get update"
- unless: test -e /etc/apt/sources.list.d/chris-lea-redis-server-precise.list
redis-server:
pkg:
- installed
- require:
- cmd: add_redis_ppa
service:
- running
- watch:
- file: /etc/redis/redis.conf
/etc/redis/redis.conf:
file.managed:
- source: salt://bamboo-base-image-pg93/redis.conf.jinja
- template: jinja
- user: redis
- group: redis
- mode: 660
- require:
- pkg: redis-server
# Postgres
# Set Postgres Version
{% set POSTGRES_VER = '9.3' %}
install-postgres-packages:
pkg.installed:
- names:
- postgresql-{{ POSTGRES_VER }}
- postgresql-client-{{ POSTGRES_VER }}
- postgresql-contrib-{{ POSTGRES_VER }}
- postgresql-server-dev-{{ POSTGRES_VER }}
- require:
- file: /etc/apt/sources.list.d/pgdg.list
- cmd: add-postgres-key
- cmd: update-postgres-apt
postgres-hba-conf:
file.managed:
- name: /etc/postgresql/{{ POSTGRES_VER }}/main/pg_hba.conf
- source: salt://bamboo-base-image-pg93/etc/postgresql/{{ POSTGRES_VER }}/main/pg_hba.conf
- user: postgres
- group: postgres
- require:
- pkg: install-postgres-packages
- cmd: rebuild-using-UTF8
postgres-conf:
file.managed:
- name: /etc/postgresql/{{ POSTGRES_VER }}/main/postgresql.conf
- source: salt://bamboo-base-image-pg93/etc/postgresql/{{ POSTGRES_VER }}/main/postgresql.conf
- user: postgres
- group: postgres
- require:
- pkg: install-postgres-packages
- cmd: rebuild-using-UTF8
postgres-path:
file.managed:
- name: /etc/profile.d/postgres.sh
- source: salt://bamboo-base-image-pg93/etc/profile.d/postgres.sh
- user: root
- group: root
# initdb is setting up the encoding to be LATIN1 despite earlier locale
# settings. Destroy and rebuild using UTF8.
rebuild-using-UTF8:
cmd.run:
- name: pg_dropcluster --stop {{ POSTGRES_VER }} main && pg_createcluster --locale=en_US.utf8 --start {{ POSTGRES_VER }} main
- require:
- pkg: install-postgres-packages
postgresql-service:
service.running:
- name: postgresql
- require:
- cmd: rebuild-using-UTF8
- watch:
- file: postgres-conf
- file: postgres-hba-conf
# Add bamboo user role to postgres
add-bamboo-role:
cmd.run:
- name: sudo -u postgres createuser -s bamboo
- runas: postgres
- require:
- cmd: rebuild-using-UTF8
create-bamboo-db:
cmd.run:
- name: sudo -u postgres createdb -O bamboo bamboo
- runas: postgres
- require:
- cmd: add-bamboo-role
# Add tantu role and db to postgres
add-tantu-role:
cmd.run:
- name: sudo -u postgres createuser -s tantu
- runas: postgres
- require:
- cmd: rebuild-using-UTF8
create-tantu-db:
cmd.run:
- name: sudo -u postgres createdb -O tantu tantu
- runas: postgres
- require:
- cmd: add-tantu-role
# Add audeincero role to postgres
add-audiencero-role:
cmd.run:
- name: sudo -u postgres createuser -s audiencero
- runas: postgres
- require:
- cmd: rebuild-using-UTF8
THIS FILE IS LOCATED AT: /srv/salt/base/postgres-repo/init.sls
add-postgres-key:
cmd.run:
- name: wget --quiet -O - http://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
/etc/apt/sources.list.d/pgdg.list:
file.managed:
- source: salt://postgres-repo/etc/apt/sources.list.d/pgdg.list
update-postgres-apt:
cmd.run:
- name: apt-get update
- require:
- cmd: add-postgres-key
- file: /etc/apt/sources.list.d/pgdg.list
#####################################################################
# Base States #
#####################################################################
base:
'*':
- tools
- motd
- python-stack
- users
- rsyslog
#####################################################################
# Development States #
#####################################################################
dev:
'dev*':
- social-misc
'roles:dev-bamboo-image-pg93':
- match: grain
- bamboo-base-image-pg93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment