Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
wattsworth
/
puppet
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d79037ac
authored
May 16, 2019
by
source_reader
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
added first use and cleanup script
parent
427424aa
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
17 deletions
cleanup.sh
first_use.sh
modules/rails_api/manifests/init.pp
rpi_apply.sh
cleanup.sh
100644 → 100755
View file @
d79037ac
#!/bin/bash
set
-e
echo
"MAKE SURE TO delete joule database and referesh installation on systemd!!"
userdel ubuntu
rm
-rf
/home/ubuntu
echo
"1] Remove the databases"
sudo
-u
postgres psql
<<
END_OF_SQL
DROP DATABASE joule;
DROP DATABASE rails;
END_OF_SQL
echo
"3] Erasing module and stream configurations"
rm /etc/joule/module_configs/
*
.conf
rm /etc/joule/stream_configs/
*
.conf
echo
"4] Removing default key material"
rm /etc/joule/security/
*
rm /opt/api/config/secrets.yml
first_use.sh
0 → 100755
View file @
d79037ac
echo
"1] Creating PostgreSQL passwords"
RAILS_PWD
=
"
$(
openssl rand
-hex
8
)
"
JOULE_PWD
=
"
$(
openssl rand
-hex
8
)
"
sudo
-u
postgres psql
<<
END_OF_SQL
DROP DATABASE IF EXISTS joule;
DROP DATABASE IF EXISTS rails;
CREATE DATABASE joule;
CREATE DATABASE rails;
GRANT ALL PRIVILEGES ON DATABASE rails TO rails;
GRANT ALL PRIVILEGES ON DATABASE joule TO joule;
ALTER ROLE rails WITH PASSWORD '
$RAILS_PWD
';
ALTER ROLE joule WITH PASSWORD '
$JOULE_PWD
';
END_OF_SQL
echo
"1] Creating Joule keys"
rm
-f
/etc/joule/main.conf
joule admin initialize
--dsn
joule:
$JOULE_PWD
@localhost:5432/joule
service joule restart
echo
"2] Creating rails secret"
cd
/opt/api
KEY
=
"
$(
bundle
exec
rake secret
)
"
cd
-
cat
>
/opt/api/config/secrets.yml
<<
EOF
production:
secret_key_base:
$KEY
EOF
echo
"3] Updating rails database.yml"
cat
>
/opt/api/config/database.yml
<<
EOF
production:
adapter: postgresql
database: rails
host: localhost
pool: 5
encoding: unicode
username: rails
password:
$RAILS_PWD
EOF
echo
"4] Migrating rails database"
export
RAILS_ENV
=
production
cd
/opt/api
#sudo -E -u rails bundle exec rake db:migrate
cd
-
echo
"5] Restarting Apache"
apache2ctl restart
modules/rails_api/manifests/init.pp
View file @
d79037ac
...
...
@@ -22,7 +22,7 @@ class rails_api {
provider
=>
git
,
source
=>
'https://git.wattsworth.net/wattsworth/control-api.git'
,
require
=>
User
[
'rails'
],
notify
=>
[
Exec
[
'bundle_install'
,
'db_migrate'
,
'local_bootstrap'
],
File
[
'/opt/api/config/database.yml'
]],
notify
=>
[
Exec
[
'bundle_install'
,
'db_migrate'
],
File
[
'/opt/api/config/database.yml'
]],
owner
=>
'rails'
}
...
...
@@ -30,7 +30,7 @@ class rails_api {
source
=>
'puppet:///modules/rails_api/database.yml'
,
owner
=>
'rails'
,
group
=>
'rails'
,
mode
=>
'064
4
'
,
mode
=>
'064
0
'
,
require
=>
Vcsrepo
[
'/opt/api'
]
}
...
...
@@ -38,7 +38,7 @@ class rails_api {
content
=>
template
(
'rails_api/secrets.yml.erb'
),
owner
=>
'rails'
,
group
=>
'rails'
,
mode
=>
'064
4
'
,
mode
=>
'064
0
'
,
require
=>
Vcsrepo
[
'/opt/api'
]
}
# remove bootsnap because it crashes on RPi's
...
...
@@ -86,13 +86,13 @@ class rails_api {
}
#create initial models in the database
exec
{
'local_bootstrap'
:
command
=>
'bundle exec rake local:bootstrap'
,
cwd
=>
'/opt/api'
,
environment
=>
[
'RAILS_ENV=production'
],
path
=>
[
'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
],
user
=>
'rails'
,
refreshonly
=>
true
,
require
=>
[
Vcsrepo
[
'/opt/api'
],
Package
[
'bundler'
],
Exec
[
'db_migrate'
]]
}
#
exec {'local_bootstrap':
#
command => 'bundle exec rake local:bootstrap',
#
cwd => '/opt/api',
#
environment => ['RAILS_ENV=production'],
#
path => ['/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'],
#
user => 'rails',
#
refreshonly => true,
#
require => [Vcsrepo['/opt/api'],Package['bundler'],Exec['db_migrate']]
#
}
}
rpi_apply.sh
View file @
d79037ac
...
...
@@ -8,5 +8,5 @@ r10k puppetfile install --moduledir=./forge_modules
# run puppet
export
FACTER_PLATFORM
=
"rpi"
puppet apply
--verbose
--
debug
--modulepath
=
./forge_modules:./modules site.pp
puppet apply
--verbose
--
modulepath
=
./forge_modules:./modules site.pp
# --debug
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment