charmkit 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +61 -44
  3. data/charmkit.gemspec +1 -1
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c878e1c9969cd28bfe668eec949485e42a82e45
4
- data.tar.gz: 191e80b46dfdb070b102b96676af194251389dcf
3
+ metadata.gz: 3519af554753017d8e7c77959346ac4f940c8428
4
+ data.tar.gz: e341f3c8fe1a68e968fc413abb1f0f349ef6fa38
5
5
  SHA512:
6
- metadata.gz: 07a8742a86c0e9965789bfbf9538e4243d560d176c43ba9f046164438a40e53d6819e75085460641bd2e7a0410333a33d684347a1ee0e8610d8d8584b77d9491
7
- data.tar.gz: 1f8388bda4197f7d62ceb69b31a9e53f85d893aaf0b1e1f65982dc204bd41498fcb200a3285bb81fc9c11e6e3950318cf1317cb5190692adb05a3863d11511ac
6
+ metadata.gz: 1b42e25af103f7f53002fd5027ee149a93f7741f5d84996def178085f4a3e82b1286d8a441429d49bfc2b167c7b92b59e06306ac2f2f4fcc8de7ba4ebc21914f
7
+ data.tar.gz: a2a68033f643ac43a05b425cbf3dcdf69125b127bf9bbf78ee81500e0af14d1c79825531e9709b4124509240d2d37ccfa59cb7df010cae14599c28e5180deee6
data/README.md CHANGED
@@ -25,21 +25,20 @@ In **hooks/install**:
25
25
  #!/bin/sh
26
26
 
27
27
  apt-get update
28
- apt-get install -qyf ruby --no-install-recommends
28
+ apt-get install -qyf ruby bundler --no-install-recommends
29
29
  gem install bundler
30
30
 
31
- bundle install --local --quiet
31
+ bundle install --local --quiet --without development
32
32
 
33
- # Runs the lib/install.rb hook
34
- bundle exec charmkit hook install
33
+ bundle exec rake dokuwiki:install
35
34
  ```
36
35
 
37
- In other hooks call *charmkit* with the execing hook (eg. **hooks/config-changed**)
36
+ In other hooks call relevant rake tasks (eg. **hooks/config-changed**)
38
37
 
39
38
  ```
40
39
  #!/bin/sh
41
40
 
42
- bundle exec charmkit hook config-changed
41
+ bundle exec rake dokuwiki:config_changed
43
42
  ```
44
43
 
45
44
  Same for **hooks/upgrade-charm**
@@ -47,78 +46,96 @@ Same for **hooks/upgrade-charm**
47
46
  ```
48
47
  #!/bin/sh
49
48
 
50
- bundle exec charmkit hook upgrade-charm
49
+ bundle exec rake dokuwiki:upgrace_charm
51
50
  ```
52
51
 
53
52
  ## Writing Charmkit style hooks
54
53
 
55
- All Charmkit hooks must reside in the charm's toplevel **lib/** directory. Those
56
- files must match the name of the hook you want to assicate to and must end with
57
- a **.rb** extension.
58
-
59
- For example, if my hook runs `bundle exec charmkit hook config-changed` then in my
60
- **lib/** directory should exist a file named **lib/config-changed.rb**.
61
-
62
- To start, you'll want to inherit from the **Charmkit** class. The class name should also
63
- reflect the name of the hook being executed and should be in a standard Ruby camelcase style.
64
-
65
- See the syntax below for a the **config-changed** hook being run:
54
+ All Charmkit hooks will reside in a normal **Rakefile**.
66
55
 
67
56
  ### Syntax
68
57
 
69
58
  ```ruby
70
- class ConfigChanged < Charmkit::Hook
71
- use :nginx
59
+ require 'charmkit'
72
60
 
73
- summon do
74
- package [
75
- 'php-fpm', 'php-cgi', 'php-curl', 'php-gd', 'php-json',
76
- 'php-mcrypt', 'php-readline', 'php-mbstring', 'php-xml'
77
- ], :update_cache
61
+ namespace :dokuwiki do
78
62
 
63
+ desc "Install Dokuwiki"
64
+ task :install do
65
+ use :nginx
66
+ use :php
67
+
68
+ deps.install
69
+
70
+ app_path = config 'app_path'
71
+ resource_path = resource 'stable-release'
79
72
  hook_path = ENV['JUJU_CHARM_DIR']
80
- app_path = path(config('app_path'))
81
73
 
82
- mkdir app_path
74
+ mkdir_p app_path
75
+
76
+ run "tar", "xf", resource_path, "-C", app_path, "--strip-components=1"
83
77
 
84
- resource_path = path(resource('stable-release'))
85
- run "tar xf #{resource_path} -C #{app_path} --strip-components=1"
78
+ cp "#{hook_path}/templates/acl.auth.php", "#{app_path}/conf/acl.auth.php"
79
+ cp "#{hook_path}/templates/local.php", "#{app_path}/conf/local.php"
80
+ cp "#{hook_path}/templates/plugins.local.php", "#{app_path}/conf/plugin.local.php"
86
81
 
87
- rm app_path/"conf/install.php"
88
- status :active, "Dokuwiki configuration updated."
82
+ version = File.read "#{app_path}/VERSION"
83
+ run "application-version-set", version.chomp
84
+ status :active, "Dokuwiki installed, please set your admin user and password with juju config dokuwiki admin_user=<an_admin_name> admin_password=<sha512 password>"
89
85
  end
90
86
 
91
- test do
92
- cmd.test '-e /etc/passwd'
87
+ desc "Configure Dokuwiki"
88
+ task :config_changed do
89
+ app_path = config 'app_path'
90
+ hook_path = ENV['JUJU_CHARM_DIR']
91
+
92
+ admin_user = config 'admin_user'
93
+ admin_password = config 'admin_password'
94
+ admin_name = config 'admin_name'
95
+ admin_email = config 'admin_email'
96
+ template "#{hook_path}/templates/users.auth.php",
97
+ "#{app_path}/conf/users.auth.php",
98
+ admin_user: admin_user,
99
+ admin_password: admin_password,
100
+ admin_name: admin_name,
101
+ admin_email: admin_email
102
+
103
+ public_address = unit 'public-address'
104
+ template "#{hook_path}/templates/vhost.conf",
105
+ "/etc/nginx/sites-enabled/default",
106
+ public_address: public_address,
107
+ app_path: app_path
108
+
109
+ chown_R 'www-data', 'www-data', app_path
110
+
111
+ run "systemctl restart php7.0-fpm"
112
+ run "systemctl restart nginx"
113
+ run "open-port 80"
114
+ status :active, "Dokuwiki updated and is now ready."
93
115
  end
94
116
  end
117
+
118
+ task :default => 'dokuwiki:install'
95
119
  ```
96
120
 
97
- The core of Charmkit is relatively small and everything is handled through
98
- scrolls (read
99
- plugins). [Visit Charmkit Scrolls](https://github.com/charmkit/charmkit-scrolls)
100
- for more information.
121
+ The core of Charmkit contains a few helpers such as template rendering but otherwise kept relatively small.
101
122
 
102
123
 
103
124
  ## Packaging the Charm
104
125
 
105
126
  ```
106
- $ bundle exec charmkit build
127
+ $ bundle package
107
128
  ```
108
129
 
109
130
  This will package and cache all required gems, along with making sure the necessary
110
- scrolls are included. The output will be a charm that you can deploy via:
111
-
112
- ```
113
- $ juju deploy dist/.
114
- ```
131
+ scrolls are included.
115
132
 
116
133
  ## Uploading to charm store
117
134
 
118
135
  Once the charm is built simply run:
119
136
 
120
137
  ```
121
- $ charm push dist/.
138
+ $ charm push .
122
139
  ```
123
140
 
124
141
  ## Development
data/charmkit.gemspec CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "charmkit"
7
- spec.version = "1.0.1"
7
+ spec.version = "1.0.2"
8
8
  spec.authors = ["Adam Stokes"]
9
9
  spec.email = ["battlemidget@users.noreply.github.com"]
10
10
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: charmkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Stokes
@@ -208,7 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  version: '0'
209
209
  requirements: []
210
210
  rubyforge_project:
211
- rubygems_version: 2.6.8
211
+ rubygems_version: 2.5.1
212
212
  signing_key:
213
213
  specification_version: 4
214
214
  summary: Helps with charm authoring