summaryrefslogtreecommitdiff
path: root/3 Resources/Puppet
diff options
context:
space:
mode:
Diffstat (limited to '3 Resources/Puppet')
-rw-r--r--3 Resources/Puppet/Classes.md14
-rw-r--r--3 Resources/Puppet/Declaring classes.md27
-rw-r--r--3 Resources/Puppet/ERB template.md11
-rw-r--r--3 Resources/Puppet/Replace a line in a file.md32
-rw-r--r--3 Resources/Puppet/Resource type references.md6
-rw-r--r--3 Resources/Puppet/Sensitive type.md17
6 files changed, 107 insertions, 0 deletions
diff --git a/3 Resources/Puppet/Classes.md b/3 Resources/Puppet/Classes.md
new file mode 100644
index 0000000..701d9b0
--- /dev/null
+++ b/3 Resources/Puppet/Classes.md
@@ -0,0 +1,14 @@
+---
+tags:
+ - puppet
+references:
+ - https://www.puppet.com/docs/puppet/7/lang_classes#lang_classes
+---
+Contains resource declarations
+Written in manifest files, 1 class per file
+Declare class to manage -> [[Declaring classes]]
+Classname -> unique
+Reusable, 1 per node
+
+Can have parameters, prefer supplying defaults, not having default == required.
+`$title` and `$name` are always there and can't be defined by user. \ No newline at end of file
diff --git a/3 Resources/Puppet/Declaring classes.md b/3 Resources/Puppet/Declaring classes.md
new file mode 100644
index 0000000..793d4b3
--- /dev/null
+++ b/3 Resources/Puppet/Declaring classes.md
@@ -0,0 +1,27 @@
+---
+tags:
+ - puppet
+references:
+ - https://www.puppet.com/docs/puppet/7/lang_classes#lang_class_declare
+---
+Prefer include over resource-like; more flexible and idempotent. Resource-like to pass args without needing to use hieradata.
+
+> Mixing declaration types for the same class can lead to compilation errors.
+
+# Include-like <- preferred
+Relies on external data, e.g hieradata, and defaults.
+Idempotent: it is only added to the catalog once.
+
+### `include`
+Accepts: single class, class reference (`Class[..]`), comma-seperated list of those or an array of them.
+
+## `require`
+Same as above - but the class becomes a dependency of the container. #clarify dependency.
+
+## `contain`
+Adheres to same rules as above. Relationships of the containing class extend to the contained class.
+See [[Containment]].
+
+# Resource-like
+Can be declared only once.
+Must be unique to avoid conflicting parameter values. \ No newline at end of file
diff --git a/3 Resources/Puppet/ERB template.md b/3 Resources/Puppet/ERB template.md
new file mode 100644
index 0000000..08b47f4
--- /dev/null
+++ b/3 Resources/Puppet/ERB template.md
@@ -0,0 +1,11 @@
+---
+tags:
+ - erb
+ - ruby
+ - template
+ - "#puppet"
+---
+`<%-` trims indentation
+`-%>` trims line-breaks
+
+In case of if-else \ No newline at end of file
diff --git a/3 Resources/Puppet/Replace a line in a file.md b/3 Resources/Puppet/Replace a line in a file.md
new file mode 100644
index 0000000..5a6f23b
--- /dev/null
+++ b/3 Resources/Puppet/Replace a line in a file.md
@@ -0,0 +1,32 @@
+---
+tags:
+ - puppet
+---
+```
+ file_line {
+ '/etc/sysconfig/libvirt-guests onboot':
+ path => '/etc/default/libvirt-guests',
+ line => 'ON_BOOT=ignore',
+ match => 'ON_BOOT=';
+ '/etc/libvirt/qemu.conf vnctls':
+ path => '/etc/libvirt/qemu.conf',
+ line => 'vnc_tls = 0',
+ match => '^#?vnc_tls = ',
+ notify => Service['libvirt'];
+ '/etc/libvirt/qemu.conf vnctls_verify':
+ path => '/etc/libvirt/qemu.conf',
+ line => 'vnc_tls_x509_verify = 0',
+ match => 'vnc_tls_x509_verify =',
+ notify => Service['libvirt'];
+ '/etc/libvirt/qemu.conf tls':
+ path => '/etc/libvirt/qemu.conf',
+ match => '^default_tls_x509_cert_dir = "/etc/pki/qemu"$',
+ line => '#default_tls_x509_cert_dir = "/etc/pki/qemu"',
+ notify => Service['libvirt'];
+ '/etc/libvirt/qemu.conf tls_verify':
+ path => '/etc/libvirt/qemu.conf',
+ match => '^default_tls_x509_verify = 1$',
+ line => '#default_tls_x509_verify = 1',
+ notify => Service['libvirt'];
+ }
+```
diff --git a/3 Resources/Puppet/Resource type references.md b/3 Resources/Puppet/Resource type references.md
new file mode 100644
index 0000000..b0f2b36
--- /dev/null
+++ b/3 Resources/Puppet/Resource type references.md
@@ -0,0 +1,6 @@
+---
+tags:
+ - puppet
+ - reference
+---
+- [User](https://www.puppet.com/docs/puppet/7/types/user.html)
diff --git a/3 Resources/Puppet/Sensitive type.md b/3 Resources/Puppet/Sensitive type.md
new file mode 100644
index 0000000..eed8e85
--- /dev/null
+++ b/3 Resources/Puppet/Sensitive type.md
@@ -0,0 +1,17 @@
+---
+tags:
+ - puppet
+references:
+ - https://www.puppet.com/docs/puppet/7/lang_data_sensitive.html
+---
+Cannot be used as a typedef in the class arguments because hieradata doesn't pass it as such but as a regular string.
+
+The `unwrap` method gives access to the original data.
+
+It doesn't encrypt anything - its only purpose is the hiding of data from logs and reports.
+
+To use Sensitive with a template we can wrap the `template` reference in it. Such as this:
+```
+'/etc/dnsdist/dnsdist.conf':
+ content => Sensitive(template('profile/application/dnsdist.conf.erb'));
+```