Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure icingaweb2 with DB and initial user #36

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions icinga2/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ icinga2:
password:
host: 127.0.0.1
port: 5432
login:
username: admin
# None => lets the state fail which is desired!
password:
schema_path: /usr/share/icingaweb2/etc/schema/pgsql.schema.sql
pkgs:
- icingaweb2
- icingaweb2-module-doc
Expand Down
2 changes: 2 additions & 0 deletions icinga2/icinga-web2-core.sls
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ icinga2-web2-required-packages:
icinga2-web2:
pkg.installed:
- pkgs: {{ icinga2.icinga_web2.pkgs | json }}
- require:
- pkg: icinga2-web2-required-packages

{%- for name, enable in icinga2.icinga_web2.features.items() %}
{{ feature(name, enable) }}
Expand Down
11 changes: 11 additions & 0 deletions icinga2/icinga-web2-database.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ is-icinga2web-password-set:
test.check_pillar:
- present:
- 'icinga2:lookup:icinga_web2:db:password'
- 'icinga2:lookup:icinga_web2:login:password'
- string:
- 'icinga2:lookup:icinga_web2:db:password'
- 'icinga2:lookup:icinga_web2:login:password'

#Create an empty database which will be populated later
icinga2web-db-setup:
Expand All @@ -29,3 +31,12 @@ icinga2web-db-setup:
- require:
- test: is-icinga2web-password-set
- postgres_user: icinga2web-db-setup
cmd.run:
- name: ( cat {{ icinga2.icinga_web2.schema_path }}; echo "INSERT INTO icingaweb_user (name, active, password_hash) VALUES ('{{ icinga2.icinga_web2.login.username }}', 1, '$(php -r 'echo password_hash("{{ icinga2.icinga_web2.login.password }}", PASSWORD_DEFAULT);')');" ) | psql -U "{{ icinga2.icinga_web2.db.user }}" -d "{{ icinga2.icinga_web2.db.name }}" -h "{{ icinga2.icinga_web2.db.host }}"
- env:
- PGPASSWORD: "{{ icinga2.icinga_web2.db.password }}"
- onchanges:
- postgres_database: icinga2web-db-setup
- require:
- postgres_database: icinga2web-db-setup
- postgres_user: icinga2web-db-setup
4 changes: 4 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ icinga2:
db:
# MUST BE SET when using icinga2.icinga-web2-database
password: AnotherSecurePassword
login:
username: admin
# MUST BE SET for UI user "admin"
password:
pkgs:
- ...
required_pkgs:
Expand Down