puppet_sslforfree
Version information
This version is compatible with:
- Puppet Enterprise 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.0.0 < 6.0.0
- , , ,
Tasks:
- puppet_sslforfree
Start using this module
Add this module to your Puppetfile:
mod 'aeciopires-puppet_sslforfree', '1.3.1'
Learn more about managing modules with a PuppetfileDocumentation
puppet_sslforfree
Menu
Português
Este é o modulo puppet_sslforfree.
Instala e gerencia o certificado assinado pelos sites:
Também cria o certificado no formato JKS.
Para aprender mais sobre o uso do Puppet, recomendo a leitura do livro que publiquei pela Novatec:
https://novatec.com.br/livros/puppet
Veja também os links que estão nesta página:
http://blog.aeciopires.com/primeiros-passos-com-o-puppet
Requisitos
- Acesse um dos sites anteriores e gere o certificado de host ou wildcard conforme as instruções disponíveis. Ambos usam a API do Let's encrypt para assinar os certificados válidos e gratuitos com duração de 90 dias.
- Puppet 4.x ou superior
- Sistema operacional: Debian 8.x, 9.x, CentOS 6.x, 7.x, Red Hat 6.x e 7.x, Ubuntu 14.04, 16.04 e 18.04.
- Instalar o pacote
keytool
obtido junto com o Java. Este módulo não instala o Java.
Observações:
- Para atualizar/renovar o certificado basta mudar o valor do parâmetro
overwrite_certificate
paratrue
e informar a nova URL de download emcert_download_url_base
, após gerar o novo certificado e salvá-lo em um servidor web. - Este módulo não configura os serviços para usar o certificado. Isso deve ser feito por outro módulo Puppet ou manualmente.
Instruções de Uso
Baixe o módulo em: https://github.com/aeciopires/puppet_sslforfree/releases
Descompacte o pacote e copiar o diretório puppet_sslforfree para a máquina puppetserver.
Na máquina puppetserver, mova o diretório puppet_sslforfree
para o diretório de módulos, por exemplo:
/etc/puppetlabs/code/environments/NAME_ENVIRONMENT/modules/. Onde NAME_ENVIRONMENT
deve ser trocado pelo nome do environment que você
quer usar no PuppetServer.
Edite o aquivo
/etc/puppetlabs/code/environments/NAME_ENVIRONMENT/manifests/site.pp
e definir quais hosts usarão o módulo, conforme o exemplo abaixo. Exemplo
da configuração do arquivo site.pp
.
node node1.domain.com.br {
include puppet_sslforfree
}
Execute o Puppet Agent no servidor node1.domain.com.br
.
puppet agent -t
Hiera
O módulo puppet_sslforfree instala e configura o certificado com as configurações definidas em parâmetros ou variáveis declaradas no manifest params.pp.
Algumas variáveis possuem valores customizados de acordo com o servidor. Estes valores são obtidos através do Hiera (com dados armazenados em arquivos do tipo "*.yaml").
Abaixo está um exemplo do arquivo de configuração do Hiera, que deve ficar localizado em: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hiera.yaml
---
version: 5
defaults:
datadir: hieradata
data_hash: yaml_data
hierarchy:
- name: "Hosts"
paths:
- "host/%{::trusted.certname}.yaml"
- "host/%{::facts.networking.fqdn}.yaml"
- "host/%{::facts.networking.hostname}.yaml"
- name: "Dominios"
paths:
- "domain/%{::trusted.domain}.yaml"
- "domain/%{::domain}.yaml"
- name: "Dados comuns"
path: "common.yaml"
Dessa forma, o Hiera buscará, prioritariamente, os valores definidos nas variáveis de host (sobrepondo os valores de variáveis de mesmo nome definidas por domínio). Estas variáveis devem ficar em arquivos como esse: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/host/node1.domain.com.br.yaml.
Caso não sejam definidos valores para variáveis nos arquivos de hosts, o Hiera buscará valores definidos em variáveis de domínio. As variáveis de domínio devem ficar em arquivos como esse: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/domain/domain.com.br.yaml.
As variáveis definidas no arquivo /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/common.yaml, só serão aplicadas em último caso.
Mesmo que nenhum destes arquivos existam, serão aplicados os valores padrão definidos na classe params.pp.
Exemplo do arquivo .yaml
#---------------------
#BEGIN
#---------------------
#Espaco requerido: 2 MB ou 2.000.000 bytes
space_required: 2000000
tmp_dir: '/tmp'
manage_certificate_jks: true
overwrite_certificate: false
download_certificate: true
cert_download_url_base: 'https://192.168.0.1/cert'
keytool: '/usr/bin/keytool'
host_cert_key: 'private.key'
host_cert_crt: 'certificate.crt'
ca_cert: 'ca_bundle.crt'
host_cert_pass: ''
cert_alias: 'sslfree'
ca_cert_alias: 'ca_sslfree'
certs_dir: '/etc/sslfree'
java_cacert: '/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts'
#---------------------
#END
#---------------------
English
This is the puppet_sslforfree module.
Installs and manages the certificate signed by the sites:
It also creates the certificate in JKS format.
Requirements
- Access one of the sites previous and generate the host or wildcard certificate. Both use the Let's encrypt API to sign the valid and free certificates with a duration of 90 days.
- Puppet 4.x or higher
- Operating System: Debian 8.x, 9.x, CentOS 6.x, 7.x, Red Hat 6.x and 7.x, Ubuntu 14.04, 16.04 and 18.04.
- Install the
keytool
packages obtained with Java. This module does not installs Java.
Comments:
- To update/renew the certificate, simply change the value of the parameter
overwrite_certificate
totrue
and enter the new download URL atcert_download_url_base
after generating the new certificate and save it to a web server. - This module does not configure services to use the certificate. You MUST be done by another Puppet module or manually.
Instructions
Download the module in: https://github.com/aeciopires/puppet_sslforfree/releases
Unzip the package and copy the puppet_sslforfree directory to the puppetserver machine.
On the puppetserver machine, move the directory puppet_sslforfree
to the modules directory, for example:
/etc/puppetlabs/code/environments/NAME_ENVIRONMENT/modules/. Where NAME_ENVIRONMENT
should be changed by the name of the environment
you want to use in PuppetServer.
Edit the file
/etc/puppetlabs/code/environments/NAME_ENVIRONMENT/manifests/site.pp
and define which hosts will use the module, as shown in the example below.
Example of the configuration of the site.pp
file
node node1.domain.com.br {
include puppet_sslforfree
}
Run the Puppet Agent on the node1.domain.com
server.
puppet agent -t
Hiera
The puppet_sslforfree module installs and configures the certificate with the settings defined in parameters or variables declared in the manifest params.pp.
Some variables have custom values according to the server. These values are obtained through Hiera (with data stored in files of type "* .yaml").
Below is an example of the Hiera configuration file, which should be located at: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hiera.yaml
---
version: 5
defaults:
datadir: hieradata
data_hash: yaml_data
hierarchy:
- name: "Hosts"
paths:
- "host/%{::trusted.certname}.yaml"
- "host/%{::facts.networking.fqdn}.yaml"
- "host/%{::facts.networking.hostname}.yaml"
- name: "Domains"
paths:
- "domain/%{::trusted.domain}.yaml"
- "domain/%{::domain}.yaml"
- name: "Common"
path: "common.yaml"
In this way, Hiera will seek, as a priority, the values defined in the variables (overlapping variable values of the same name defined by the domain). These variables should be in files like this: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/host/node1.domain.com.br.yaml.
If no value is set for variables in the hosts files, Hiera will look for values defined in domain variables. The variables domain MUST be in files like this: /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/domain/domain.com.br.yaml.
The variables defined in the /etc/puppetlabs/code/environments/NAME_ENVIRONMENT/hieradata/common.yaml file, will only be applied in the latter case.
Even if none of these files exist, the default values defined in the params.pp class will be applied.
Sample file .yaml
#---------------------
#BEGIN
#---------------------
#Space Required: 2 MB or 2.000.000 bytes
space_required: 2000000
tmp_dir: '/tmp'
manage_certificate_jks: true
overwrite_certificate: false
download_certificate: true
cert_download_url_base: 'https://192.168.0.1/cert'
keytool: '/usr/bin/keytool'
host_cert_key: 'private.key'
host_cert_crt: 'certificate.crt'
ca_cert: 'ca_bundle.crt'
host_cert_pass: ''7
cert_alias: 'sslfree'
ca_cert_alias: 'ca_sslfree'
certs_dir: '/etc/sslfree'
java_cacert: '/usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts'
#---------------------
#END
#---------------------
Parameters
space_required
Description: Sets the minimum required disk space.
Data type: Interger.
Default value: 2000000 (in bytes).
tmp_dir
Description: Sets the temporary directory.
Data type: String.
Default value: /tmp
manage_certificate_jks
Description: If true
, it manages the certificate. If false
does
nothing.
Data type: Boolean.
Default value: true
overwrite_certificate
Description: If true
, overwrite the certificate with the same alias
every round of the puppet agent. If false
, keep the certificate and to
register the new you must change the alias of the new certificate in the
parameters: cert_alias
and ca_cert_alias
.
Data type: Boolean.
Default value: false
download_certificate
Description: If true
, download the certificate from the URL formed by
the concatenation of the parameters: $cert_download_url_base/$host_cert_key
,
$cert_download_url_base/$host_cert_crt
and
$cert_download_url_base/$ca_cert
. If false
, you must to update the
content of the files in the module directory in files/certs_sslfree
.
Data type: Boolean.
Default value: true
cert_download_url_base
Description: Certificate download base URL.
Data type: String.
Default value: https://192.168.0.1/cert
keytool
Description: Path of the keytool binary in the operating system. Keytool is obtained by installing Java. This module does not manage Java installation
Data type: String.
Default value: /usr/bin/keytool
host_cert_key
Description: Name of the private key file. The name of this file will be
concatenated with the URL entered in the parameter cert_download_url_base
.
Data type: String.
Default value: private.key
host_cert_crt
Description: Name of the certificate file. The name of this file will be
concatenated with the URL entered in the parameter cert_download_url_base
.
Data type: String.
Default value: certificate.crt
ca_cert
Description: Name of the certificate file of the Certificate Authority.
The name of this file will be concatenated with the URL entered in the
parameter cert_download_url_base
.
Data type: String.
Default value: ca_bundle.crt
host_cert_pass
Description: Certificate password.
Data type: String.
Default value: ' ' (empty)
cert_alias
Description: Certificate alias. This module uses the keytool to create a repository JKS so that the certificate can be used by applications or Java application servers.
Data type: String.
Default value: sslfree
ca_cert_alias
Description: Alias of the Certificate Authority. This module uses the keytool to create a repository JKS so that the certificate can be used by applications or Java application servers.
Data type: String.
Default value: ca_sslfree
certs_dir
Description: Directory in which the certificates will be stored.
Data type: String.
Default value: /etc/sslfree
java_cacert
Description: Repository JKS of the Java for storing Certificate Authority certificates. See https://en.wikipedia.org/wiki/Keystore.
Data type: String.
Default value: /usr/lib/jvm/java-8-oracle/jre/lib/security/cacerts
Developers
developer: Aecio dos Santos Pires mail: aeciopires at gmail.com
License
Apache 2.0 2018 Aécio dos Santos Pires
What are tasks?
Modules can contain tasks that take action outside of a desired state managed by Puppet. It’s perfect for troubleshooting or deploying one-off changes, distributing scripts to run across your infrastructure, or automating changes that need to happen in a particular order as part of an application deployment.
Tasks in this module release
Change log
All notable changes to this project will be documented in this file. The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
2018-04-30 Release [1.3.1]
Summary
This is a minor release, it includes documentation update.
2018-04-29 Release [1.3.0]
Summary
This is a minor release, it includes enhancements to the documentation and support to https://zerossl.com and https://gethttpsforfree.com.
Added
- Parameter overwrite_certificate. See README.md
- Updated documentation
2018-04-28 Release [1.2.0]
Summary
This is a minor release, it includes enhancements to the documentation and new configuration parameter and code snippet that can replace an existing certificate in a JKS repository.
Added
- Parameter overwrite_certificate. See README.md
- Updated documentation
2018-04-24 Release [1.1.0]
Summary
This is a minor release, it makes this module PDK-compliant for easier maintenance and includes task for execution with Puppet-Bolt.
Added
- PDK conversion.
- Tasks. See TASK_README.md
- Updated documentation
2018-04-23 Release [1.0.2]
Summary
This is a pacth release, it includes the parameter to support the path of java_cacerts.
Added
- Parameter 'java_cacert'.
- Support added for Ubuntu 18.04.
2018-04-23 Release 1.0.1
Summary
Bad release. Error in documentation.
2018-04-23 Release 1.0.0
Summary
Publish module. Hello Word! :-)
Dependencies
- puppetlabs/stdlib (>= 4.17.0 < 8.0.0)
Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.