Skip to content

Commit

Permalink
Merge pull request #49 from dnsimple/certificate_docs
Browse files Browse the repository at this point in the history
Add Docs for dnsimple_certificate
  • Loading branch information
onlyhavecans committed Jun 26, 2017
2 parents 45286b0 + c81fc73 commit 493db21
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 61 deletions.
160 changes: 102 additions & 58 deletions README.md
Expand Up @@ -21,37 +21,36 @@ If you used the 1.x series of this cookbook please carefully review your usage o

## Resources/Providers

dnsimple\_record
----------------
### dnsimple\_record

Manage a DNS record through the dnsimple API. This resource uses the
[dnsimple Ruby library](https://rubygems.org/gems/dnsimple) to connect and use
the dnsimple API. This resource also exposes a ChefSpec matcher for you to do
unit testing as well.

### Actions:
#### Actions:

| Action | Description | Default |
|-----------|----------------------|---------|
| *create* | Create the record. | Yes |
| *update* | Update the record. | |
| *destroy* | Destroy the record. | |
| Action | Description | Default |
|-----------|----------------------|---------|
| *create* | Create the record. | Yes |
| *update* | Update the record. | |
| *destroy* | Destroy the record. | |

### Parameter Attributes:
#### Parameter Attributes:

The type of record can be one of the following: A, CNAME, ALIAS, MX,
SPF, URL, TXT, NS, SRV, NAPTR, PTR, AAA, SSHFP, or HFINO.

| Parameter | Description | Required | Default |
| ------------ | --------------------------------- | -------- | --------- |
| *domain* | Domain to manage | true | |
| *name* | Name of the record | | Apex of the domain |
| *type* | Type of DNS record | true | |
| *content* | String/Array content of records | true | |
| *ttl* | Time to live | | 3600 |
| *priority* | Priorty of record | | |
| *regions* | Specific regions for this record | | |
| *token* | DNSimple API token | | |
| Parameter | Description | Required | Default |
|------------|----------------------------------|----------|--------------------|
| *domain* | Domain to manage | true | |
| *name* | Name of the record | | Apex of the domain |
| *type* | Type of DNS record | true | |
| *content* | String/Array content of records | true | |
| *ttl* | Time to live | | 3600 |
| *priority* | Priorty of record | | |
| *regions* | Specific regions for this record | | |
| *token* | DNSimple API token | | |

**Note**: If you do not provide the name parameter, it will be assumed from the
resource name, which cannot be blank. If you want to create multiple record
Expand All @@ -62,52 +61,96 @@ name an empty string.
blank by default. If you do not have this feature available it will return
an error.

### Examples
#### Examples

Note that these examples assume you have obtained an account level access token
which is documented above (see Requirements). We're also assuming you're securely
storing your API keys in [Chef Vault](https://docs.chef.io/chef_vault.html) but
it is not a requirement.

```ruby
dnsimple_record 'fooserver' do
domain 'foo.com'
type 'A'
content '1.2.3.4'
ttl 3600
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

dnsimple_record 'create a CNAME record for a Google Apps site calendar' do
name 'calendar'
content 'ghs.google.com'
type 'CNAME'
domain 'example.com'
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

dnsimple_record "create a A record with multiple content values" do
name 'servers'
content ['1.1.1.1', '2.2.2.2']
type 'A'
domain 'example.com'
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

# Note: This only works with certain accounts, see the note above for
# regional records! The Chef run will fail otherwise.
dnsimple_record "create an A record in Tokyo only" do
name 'myserverinjapan'
content '2.2.2.2'
type 'A'
domain 'example.com'
regions ['tko']
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end
dnsimple_record 'fooserver' do
domain 'foo.com'
type 'A'
content '1.2.3.4'
ttl 3600
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

dnsimple_record 'create a CNAME record for a Google Apps site calendar' do
name 'calendar'
content 'ghs.google.com'
type 'CNAME'
domain 'example.com'
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

dnsimple_record "create a A record with multiple content values" do
name 'servers'
content ['1.1.1.1', '2.2.2.2']
type 'A'
domain 'example.com'
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end

# Note: This only works with certain accounts, see the note above for
# regional records! The Chef run will fail otherwise.
dnsimple_record "create an A record in Tokyo only" do
name 'myserverinjapan'
content '2.2.2.2'
type 'A'
domain 'example.com'
regions ['tko']
access_token chef_vault_item('secrets', 'dnsimple_token')
action :create
end
```

### dnsimple\_certificate

Download and install a certificate. Currently this only supports basic matched
.crt & .key files. We would like to expand this to support all formats
including java keystores. *PRs are welcome*!

This resource uses the [dnsimple Ruby
library](https://rubygems.org/gems/dnsimple) to connect and use the dnsimple
API. This resource also exposes a ChefSpec matcher for you to do unit testing
as well.


#### Actions:

| Action | Description | Default |
|-----------|-----------------------|---------|
| *install* | Install the crt & key | Yes |


#### Parameter Attributes:

| Parameter | Description | Required | Default |
|-------------------------|-----------------------------------|----------|---------|
| install_path | where the crt & key are installed | yes | |
| certificate_common_name | name of the files | yes | |
| domain | the main domain name on the crt | yes | |
| mode | files mode | no | 0600 |
| owner | files owner | no | root |
| group | files group | no | root |


#### Examples

```ruby
dnsimple_certificate '/etc/apache2/ssl' do
certificate_common_name 'www.dnsimple.xyz'
domain 'dnsimple.xyz'
access_token chef_vault_item('secrets', 'dnsimple_token')
mode '0755'
owner 'web_admin'
group 'web_admin'
end
```

## Usage
Expand All @@ -128,6 +171,7 @@ See CONTRIBUTING.md
* Author:: [Aaron Kalin](https://github.com/martinisoft)
* Author:: [David Aronsohn](https://github.com/onlyhavecans)
* Author:: [Jacobo Garcia](https://github.com/therobot)
* Author:: [Anthony Eden](https://github.com/aeden)

Copyright:: 2014-2017 Aetrion, LLC dba DNSimple

Expand Down
6 changes: 3 additions & 3 deletions libraries/resource_dnsimple_certificate.rb
Expand Up @@ -34,9 +34,9 @@ class DnsimpleCertificate < DnsimpleResource
property :chain_pem, kind_of: Array
property :private_key_pem, kind_of: String

property :mode, kind_of: String
property :owner, kind_of: String
property :group, kind_of: String
property :mode, kind_of: String, default: '0600'
property :owner, kind_of: String, default: 'root'
property :group, kind_of: String, default: 'root'
end
end
end

0 comments on commit 493db21

Please sign in to comment.