Compare commits
4 Commits
c8662002dc
...
9f1a79708e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9f1a79708e | ||
|
|
108620be8e | ||
| 77258a537e | |||
|
|
e56973b5e8 |
127
Jenkinsfile
vendored
127
Jenkinsfile
vendored
@@ -1,127 +0,0 @@
|
|||||||
pipeline {
|
|
||||||
agent {
|
|
||||||
label 'puppet'
|
|
||||||
}
|
|
||||||
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
deleteDir() /* clean up our workspace */
|
|
||||||
}
|
|
||||||
success {
|
|
||||||
updateGitlabCommitStatus state: 'success'
|
|
||||||
}
|
|
||||||
failure {
|
|
||||||
updateGitlabCommitStatus state: 'failed'
|
|
||||||
step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: 'support@confdroid.com', sendToIndividuals: true])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
options {
|
|
||||||
gitLabConnection('gitlab.confdroid.com')
|
|
||||||
}
|
|
||||||
|
|
||||||
stages {
|
|
||||||
|
|
||||||
stage('pull master') {
|
|
||||||
steps {
|
|
||||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
|
||||||
sh '''
|
|
||||||
git config user.name "Jenkins Server"
|
|
||||||
git config user.email jenkins@confdroid.com
|
|
||||||
# Ensure we're on the development branch (triggered by push)
|
|
||||||
git checkout development
|
|
||||||
# Create jenkins branch from development
|
|
||||||
git checkout -b jenkins-build-$BUILD_NUMBER
|
|
||||||
# Optionally merge master into jenkins to ensure compatibility
|
|
||||||
git merge origin/master --no-ff || { echo "Merge conflict detected"; exit 1; }
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('puppet parser') {
|
|
||||||
steps {
|
|
||||||
sh '''for file in $(find . -iname \'*.pp\'); do
|
|
||||||
/opt/puppetlabs/bin/puppet parser validate --color false --render-as s --modulepath=modules $file || exit 1;
|
|
||||||
done;'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('check templates') {
|
|
||||||
steps{
|
|
||||||
sh '''for file in $(find . -iname \'*.erb\');
|
|
||||||
do erb -P -x -T "-" $file | ruby -c || exit 1;
|
|
||||||
done;'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('puppet-lint') {
|
|
||||||
steps {
|
|
||||||
sh '''/usr/local/bin/puppet-lint . \\
|
|
||||||
--no-variable_scope-check \\
|
|
||||||
|| { echo "Puppet lint failed"; exit 1; }
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('SonarScan') {
|
|
||||||
steps {
|
|
||||||
withCredentials([string(credentialsId: 'sonar-token', variable: 'SONAR_TOKEN')]) {
|
|
||||||
sh '''
|
|
||||||
/opt/sonar-scanner/bin/sonar-scanner \
|
|
||||||
-Dsonar.projectKey=confdroid_alloy \
|
|
||||||
-Dsonar.sources=. \
|
|
||||||
-Dsonar.host.url=https://sonarqube.confdroid.com \
|
|
||||||
-Dsonar.token=$SONAR_TOKEN
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('create Puppet documentation') {
|
|
||||||
steps {
|
|
||||||
sh '/opt/puppetlabs/bin/puppet strings'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
stage('update repo') {
|
|
||||||
steps {
|
|
||||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
|
||||||
sh '''
|
|
||||||
git config user.name "Jenkins Server"
|
|
||||||
git config user.email jenkins@confdroid.com
|
|
||||||
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
|
||||||
git add -A && git commit -am "Recommit for updates in build $BUILD_NUMBER" || echo "No changes to commit"
|
|
||||||
git push origin HEAD:master
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stage('Mirror to Gitea') {
|
|
||||||
steps {
|
|
||||||
sshagent(['edd05eb6-26b5-4c7b-a5cc-ea2ab899f4fa']) {
|
|
||||||
withCredentials([usernamePassword(
|
|
||||||
credentialsId: 'Jenkins-gitea',
|
|
||||||
usernameVariable: 'GITEA_USER',
|
|
||||||
passwordVariable: 'GITEA_TOKEN')]) {
|
|
||||||
script {
|
|
||||||
// Checkout from GitLab (already done implicitly)
|
|
||||||
sh '''
|
|
||||||
git checkout master
|
|
||||||
git pull origin master
|
|
||||||
git branch -D development
|
|
||||||
git branch -D jenkins-build-$BUILD_NUMBER
|
|
||||||
git rm -f Jenkinsfile
|
|
||||||
git rm -r --cached .vscode || echo "No .vscode to remove from git"
|
|
||||||
git commit --amend --no-edit --allow-empty
|
|
||||||
git remote add master https://sourcecode.confdroid.com/confdroid/confdroid_alloy.git
|
|
||||||
git -c credential.helper="!f() { echo username=${GITEA_USER}; echo password=${GITEA_TOKEN}; }; f" \
|
|
||||||
push master --mirror
|
|
||||||
'''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
10
README.md
10
README.md
@@ -55,6 +55,7 @@ See the full Puppet documentation including parameters in `docs/index.html`
|
|||||||
All dependencies must be included in the catalogue.
|
All dependencies must be included in the catalogue.
|
||||||
|
|
||||||
- [confdroid_nagios](https://sourcecode.confdroid.com/confdroid/confdroid_nagios) if nagios monitoring is desired
|
- [confdroid_nagios](https://sourcecode.confdroid.com/confdroid/confdroid_nagios) if nagios monitoring is desired
|
||||||
|
- [puppetlabs/concat](https://forge.puppet.com/modules/puppetlabs/concat) for composing the Alloy configuration
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
|
|
||||||
@@ -68,6 +69,15 @@ node 'example.example.net' {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
External modules can add log files to Alloy's `path_targets` list with the
|
||||||
|
`confdroid_alloy::log_targets` defined type:
|
||||||
|
|
||||||
|
```puppet
|
||||||
|
confdroid_alloy::log_targets { 'my_application':
|
||||||
|
targets => ['/var/log/my_application/*.log', '/var/log/my_application/audit.log'],
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
- through Foreman:
|
- through Foreman:
|
||||||
|
|
||||||
In order to apply parameters through Foreman, the params.pp must be added to the host or host group in question.
|
In order to apply parameters through Foreman, the params.pp must be added to the host or host group in question.
|
||||||
|
|||||||
@@ -122,6 +122,30 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h2>Defined Type Listing A-Z</h2>
|
||||||
|
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td valign='top' width="33%">
|
||||||
|
|
||||||
|
|
||||||
|
<ul id="alpha_C" class="alpha">
|
||||||
|
<li class="letter">C</li>
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
<li>
|
||||||
|
<span class='object_link'><a href="puppet_defined_types/confdroid_alloy_3A_3Alog_targets.html" title="puppet_defined_types::confdroid_alloy::log_targets (puppet_defined_type)">confdroid_alloy::log_targets</a></span>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -132,6 +132,8 @@
|
|||||||
<p>All dependencies must be included in the catalogue.</p>
|
<p>All dependencies must be included in the catalogue.</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_nagios">confdroid_nagios</a> if nagios monitoring is desired</p>
|
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_nagios">confdroid_nagios</a> if nagios monitoring is desired</p>
|
||||||
|
</li><li>
|
||||||
|
<p><a href="https://forge.puppet.com/modules/puppetlabs/concat">puppetlabs/concat</a> for composing the Alloy configuration</p>
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
|
||||||
<h2 id="label-Deployment">Deployment</h2>
|
<h2 id="label-Deployment">Deployment</h2>
|
||||||
@@ -145,6 +147,13 @@
|
|||||||
include confdroid_alloy
|
include confdroid_alloy
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
|
<p>External modules can add log files to Alloy’s <code>path_targets</code> list with the <code>confdroid_alloy::log_targets</code> defined type:</p>
|
||||||
|
|
||||||
|
<pre class="code ruby"><code class="ruby">confdroid_alloy::log_targets { 'my_application':
|
||||||
|
targets => ['/var/log/my_application/*.log', '/var/log/my_application/audit.log'],
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>through Foreman:</p>
|
<p>through Foreman:</p>
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
|||||||
@@ -132,6 +132,8 @@
|
|||||||
<p>All dependencies must be included in the catalogue.</p>
|
<p>All dependencies must be included in the catalogue.</p>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_nagios">confdroid_nagios</a> if nagios monitoring is desired</p>
|
<p><a href="https://sourcecode.confdroid.com/confdroid/confdroid_nagios">confdroid_nagios</a> if nagios monitoring is desired</p>
|
||||||
|
</li><li>
|
||||||
|
<p><a href="https://forge.puppet.com/modules/puppetlabs/concat">puppetlabs/concat</a> for composing the Alloy configuration</p>
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
|
||||||
<h2 id="label-Deployment">Deployment</h2>
|
<h2 id="label-Deployment">Deployment</h2>
|
||||||
@@ -145,6 +147,13 @@
|
|||||||
include confdroid_alloy
|
include confdroid_alloy
|
||||||
}
|
}
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
|
<p>External modules can add log files to Alloy’s <code>path_targets</code> list with the <code>confdroid_alloy::log_targets</code> defined type:</p>
|
||||||
|
|
||||||
|
<pre class="code ruby"><code class="ruby">confdroid_alloy::log_targets { 'my_application':
|
||||||
|
targets => ['/var/log/my_application/*.log', '/var/log/my_application/audit.log'],
|
||||||
|
}
|
||||||
|
</code></pre>
|
||||||
<ul><li>
|
<ul><li>
|
||||||
<p>through Foreman:</p>
|
<p>through Foreman:</p>
|
||||||
</li></ul>
|
</li></ul>
|
||||||
|
|||||||
@@ -28,6 +28,10 @@
|
|||||||
Puppet Classes
|
Puppet Classes
|
||||||
</a></span>
|
</a></span>
|
||||||
|
|
||||||
|
<span><a target="_self" href="puppet_defined_type_list.html">
|
||||||
|
Defined Types
|
||||||
|
</a></span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="search">Search: <input type="text" /></div>
|
<div id="search">Search: <input type="text" /></div>
|
||||||
|
|||||||
@@ -151,7 +151,26 @@
|
|||||||
53
|
53
|
||||||
54
|
54
|
||||||
55
|
55
|
||||||
56</pre>
|
56
|
||||||
|
57
|
||||||
|
58
|
||||||
|
59
|
||||||
|
60
|
||||||
|
61
|
||||||
|
62
|
||||||
|
63
|
||||||
|
64
|
||||||
|
65
|
||||||
|
66
|
||||||
|
67
|
||||||
|
68
|
||||||
|
69
|
||||||
|
70
|
||||||
|
71
|
||||||
|
72
|
||||||
|
73
|
||||||
|
74
|
||||||
|
75</pre>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span>
|
<pre class="code"><span class="info file"># File 'manifests/main/files.pp', line 6</span>
|
||||||
@@ -160,12 +179,12 @@ class confdroid_alloy::main::files (
|
|||||||
|
|
||||||
) inherits confdroid_alloy::params {
|
) inherits confdroid_alloy::params {
|
||||||
require confdroid_alloy::main::dirs
|
require confdroid_alloy::main::dirs
|
||||||
|
include concat
|
||||||
|
|
||||||
# Ensure log_targets is always an array
|
|
||||||
$log_targets_array = Array($confdroid_alloy::params::ay_log_targets, true)
|
$log_targets_array = Array($confdroid_alloy::params::ay_log_targets, true)
|
||||||
|
|
||||||
file { $ay_main_file:
|
concat { $ay_main_file:
|
||||||
ensure => file,
|
ensure => present,
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => 'root',
|
group => 'root',
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
@@ -173,10 +192,29 @@ class confdroid_alloy::main::files (
|
|||||||
selrole => object_r,
|
selrole => object_r,
|
||||||
seltype => etc_t,
|
seltype => etc_t,
|
||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
content => template('confdroid_alloy/config.alloy.erb'),
|
|
||||||
notify => Service[$ay_service],
|
notify => Service[$ay_service],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
concat::fragment { 'confdroid_alloy_config_header':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/config.alloy.erb'),
|
||||||
|
order => '001',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $ay_manage_loki == true {
|
||||||
|
concat::fragment { 'confdroid_alloy_log_targets_default':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/log_targets.alloy.erb'),
|
||||||
|
order => '010',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concat::fragment { 'confdroid_alloy_config_tail':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/config.alloy.tail.erb'),
|
||||||
|
order => '999',
|
||||||
|
}
|
||||||
|
|
||||||
# manage logrotate for rsyslog to allow adm group membership
|
# manage logrotate for rsyslog to allow adm group membership
|
||||||
file { '/etc/logrotate.d/rsyslog':
|
file { '/etc/logrotate.d/rsyslog':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
|
|||||||
@@ -424,7 +424,7 @@
|
|||||||
<span class='type'>(<tt>String</tt>)</span>
|
<span class='type'>(<tt>String</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
<em class="default">(defaults to: <tt>'1:1'</tt>)</em>
|
<em class="default">(defaults to: <tt>'1:'</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
—
|
—
|
||||||
@@ -517,7 +517,7 @@ class confdroid_alloy::params (
|
|||||||
Boolean $ay_manage_nagios = false,
|
Boolean $ay_manage_nagios = false,
|
||||||
String $ay_target_service = '/etc/nagios/conf.d/alloy_service.cfg',
|
String $ay_target_service = '/etc/nagios/conf.d/alloy_service.cfg',
|
||||||
Array $ay_target_contacts = ['nagiosadmin'],
|
Array $ay_target_contacts = ['nagiosadmin'],
|
||||||
String $ay_procs_allowed = '1:1'
|
String $ay_procs_allowed = '1:'
|
||||||
|
|
||||||
) {
|
) {
|
||||||
# defaults
|
# defaults
|
||||||
|
|||||||
54
doc/puppet_defined_type_list.html
Normal file
54
doc/puppet_defined_type_list.html
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<title>Defined Type List</title>
|
||||||
|
<base id="base_target" target="_parent" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="content">
|
||||||
|
<div class="fixed_header">
|
||||||
|
<h1 id="full_list_header">Defined Type List</h1>
|
||||||
|
<div id="full_list_nav">
|
||||||
|
|
||||||
|
<span><a target="_self" href="puppet_class_list.html">
|
||||||
|
Puppet Classes
|
||||||
|
</a></span>
|
||||||
|
|
||||||
|
<span><a target="_self" href="puppet_defined_type_list.html">
|
||||||
|
Defined Types
|
||||||
|
</a></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="search">Search: <input type="text" /></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ul id="full_list" class="puppet_defined_type">
|
||||||
|
|
||||||
|
|
||||||
|
<li id="object_puppet_defined_types::confdroid_alloy::log_targets" class="odd">
|
||||||
|
<div class="item">
|
||||||
|
<span class='object_link'><a href="puppet_defined_types/confdroid_alloy_3A_3Alog_targets.html" title="puppet_defined_types::confdroid_alloy::log_targets (puppet_defined_type)">confdroid_alloy::log_targets</a></span>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
165
doc/puppet_defined_types/confdroid_alloy_3A_3Alog_targets.html
Normal file
165
doc/puppet_defined_types/confdroid_alloy_3A_3Alog_targets.html
Normal file
@@ -0,0 +1,165 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>
|
||||||
|
Defined Type: confdroid_alloy::log_targets
|
||||||
|
|
||||||
|
— Documentation by YARD 0.9.36
|
||||||
|
|
||||||
|
</title>
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
||||||
|
|
||||||
|
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
pathId = "puppet_defined_types::confdroid_alloy::log_targets";
|
||||||
|
relpath = '../';
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="nav_wrap">
|
||||||
|
<iframe id="nav" src="../puppet_defined_type_list.html?1"></iframe>
|
||||||
|
<div id="resizer"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="main" tabindex="-1">
|
||||||
|
<div id="header">
|
||||||
|
<div id="menu">
|
||||||
|
|
||||||
|
<a href="../_index.html">Index (c)</a> »
|
||||||
|
<span class='title'><span class='object_link'>Defined Types</span></span>
|
||||||
|
»
|
||||||
|
<span class="title">confdroid_alloy::log_targets</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="search">
|
||||||
|
|
||||||
|
<a class="full_list_link" id="puppet_class_list_link"
|
||||||
|
href="../puppet_class_list.html">
|
||||||
|
|
||||||
|
<svg width="24" height="24">
|
||||||
|
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
||||||
|
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
||||||
|
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="clear"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content"><h1>Defined Type: confdroid_alloy::log_targets</h1>
|
||||||
|
<div class="box_info">
|
||||||
|
<dl>
|
||||||
|
<dt>Defined in:</dt>
|
||||||
|
<dd>
|
||||||
|
manifests/log_targets.pp
|
||||||
|
</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>Summary</h2>
|
||||||
|
Adds log file targets to the Alloy configuration.
|
||||||
|
|
||||||
|
<h2>Overview</h2>
|
||||||
|
<div class="docstring">
|
||||||
|
<div class="discussion">
|
||||||
|
|
||||||
|
<p>confdroid_alloy::log_targets.pp Module name: confdroid_alloy</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="tags">
|
||||||
|
<p class="tag_title">Parameters:</p>
|
||||||
|
<ul class="param">
|
||||||
|
|
||||||
|
<li>
|
||||||
|
|
||||||
|
<span class='name'>targets</span>
|
||||||
|
|
||||||
|
|
||||||
|
<span class='type'>(<tt>Array[String]</tt>)</span>
|
||||||
|
|
||||||
|
|
||||||
|
<em class="default">(defaults to: <tt>[]</tt>)</em>
|
||||||
|
|
||||||
|
|
||||||
|
—
|
||||||
|
<div class='inline'>
|
||||||
|
<p>Paths to log files to scrape.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div><div class="method_details_list">
|
||||||
|
<table class="source_code">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<pre class="lines">
|
||||||
|
|
||||||
|
|
||||||
|
6
|
||||||
|
7
|
||||||
|
8
|
||||||
|
9
|
||||||
|
10
|
||||||
|
11
|
||||||
|
12
|
||||||
|
13
|
||||||
|
14
|
||||||
|
15
|
||||||
|
16
|
||||||
|
17
|
||||||
|
18
|
||||||
|
19
|
||||||
|
20</pre>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<pre class="code"><span class="info file"># File 'manifests/log_targets.pp', line 6</span>
|
||||||
|
|
||||||
|
define confdroid_alloy::log_targets (
|
||||||
|
|
||||||
|
Array[String] $targets = [],
|
||||||
|
|
||||||
|
) {
|
||||||
|
if $confdroid_alloy::params::ay_manage_loki == true and $targets != [] {
|
||||||
|
$log_targets_array = $targets
|
||||||
|
|
||||||
|
concat::fragment { "log_targets_${name}":
|
||||||
|
target => $confdroid_alloy::params::ay_main_file,
|
||||||
|
content => template('confdroid_alloy/log_targets.alloy.erb'),
|
||||||
|
order => '020',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="footer">
|
||||||
|
Generated by <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
20
manifests/log_targets.pp
Normal file
20
manifests/log_targets.pp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
## confdroid_alloy::log_targets.pp
|
||||||
|
# Module name: confdroid_alloy
|
||||||
|
# @summary Adds log file targets to the Alloy configuration.
|
||||||
|
# @param [Array[String]] targets Paths to log files to scrape.
|
||||||
|
###############################################################################
|
||||||
|
define confdroid_alloy::log_targets (
|
||||||
|
|
||||||
|
Array[String] $targets = [],
|
||||||
|
|
||||||
|
) {
|
||||||
|
if $confdroid_alloy::params::ay_manage_loki == true and $targets != [] {
|
||||||
|
$log_targets_array = $targets
|
||||||
|
|
||||||
|
concat::fragment { "log_targets_${name}":
|
||||||
|
target => $confdroid_alloy::params::ay_main_file,
|
||||||
|
content => template('confdroid_alloy/log_targets.alloy.erb'),
|
||||||
|
order => '020',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -7,12 +7,12 @@ class confdroid_alloy::main::files (
|
|||||||
|
|
||||||
) inherits confdroid_alloy::params {
|
) inherits confdroid_alloy::params {
|
||||||
require confdroid_alloy::main::dirs
|
require confdroid_alloy::main::dirs
|
||||||
|
include concat
|
||||||
|
|
||||||
# Ensure log_targets is always an array
|
|
||||||
$log_targets_array = Array($confdroid_alloy::params::ay_log_targets, true)
|
$log_targets_array = Array($confdroid_alloy::params::ay_log_targets, true)
|
||||||
|
|
||||||
file { $ay_main_file:
|
concat { $ay_main_file:
|
||||||
ensure => file,
|
ensure => present,
|
||||||
owner => 'root',
|
owner => 'root',
|
||||||
group => 'root',
|
group => 'root',
|
||||||
mode => '0644',
|
mode => '0644',
|
||||||
@@ -20,10 +20,29 @@ class confdroid_alloy::main::files (
|
|||||||
selrole => object_r,
|
selrole => object_r,
|
||||||
seltype => etc_t,
|
seltype => etc_t,
|
||||||
seluser => system_u,
|
seluser => system_u,
|
||||||
content => template('confdroid_alloy/config.alloy.erb'),
|
|
||||||
notify => Service[$ay_service],
|
notify => Service[$ay_service],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
concat::fragment { 'confdroid_alloy_config_header':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/config.alloy.erb'),
|
||||||
|
order => '001',
|
||||||
|
}
|
||||||
|
|
||||||
|
if $ay_manage_loki == true {
|
||||||
|
concat::fragment { 'confdroid_alloy_log_targets_default':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/log_targets.alloy.erb'),
|
||||||
|
order => '010',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concat::fragment { 'confdroid_alloy_config_tail':
|
||||||
|
target => $ay_main_file,
|
||||||
|
content => template('confdroid_alloy/config.alloy.tail.erb'),
|
||||||
|
order => '999',
|
||||||
|
}
|
||||||
|
|
||||||
# manage logrotate for rsyslog to allow adm group membership
|
# manage logrotate for rsyslog to allow adm group membership
|
||||||
file { '/etc/logrotate.d/rsyslog':
|
file { '/etc/logrotate.d/rsyslog':
|
||||||
ensure => file,
|
ensure => file,
|
||||||
|
|||||||
@@ -18,87 +18,4 @@ loki.process "alloy" {
|
|||||||
// Define file discovery for your logs
|
// Define file discovery for your logs
|
||||||
local.file_match "system_logs" {
|
local.file_match "system_logs" {
|
||||||
path_targets = [
|
path_targets = [
|
||||||
<% @log_targets_array.each do |target| -%>
|
|
||||||
{__path__ = "<%= target %>"},
|
|
||||||
<% end -%>
|
<% end -%>
|
||||||
]
|
|
||||||
sync_period = "5s"
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scrape the logs from the matched files
|
|
||||||
loki.source.file "system_logs" {
|
|
||||||
targets = local.file_match.system_logs.targets
|
|
||||||
forward_to = [loki.process.syslog.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.process "syslog" {
|
|
||||||
|
|
||||||
stage.static_labels {
|
|
||||||
values = {
|
|
||||||
fqdn = constants.hostname,
|
|
||||||
service = "linux_logs",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
forward_to = [loki.write.loki.receiver]
|
|
||||||
}
|
|
||||||
|
|
||||||
loki.write "loki" {
|
|
||||||
endpoint {
|
|
||||||
url = "<%= @ay_loki_url %>"
|
|
||||||
basic_auth {
|
|
||||||
username = "<%= @ay_loki_username %>"
|
|
||||||
password = "<%= @ay_loki_userpass %>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<% end -%>
|
|
||||||
<% if @ay_manage_prom == true -%>
|
|
||||||
// 1. Exporter (or keep your existing node_exporter binary)
|
|
||||||
prometheus.exporter.unix "node" {
|
|
||||||
// optional: disable unused collectors
|
|
||||||
// disable_collectors = ["ipvs", "btrfs", ...]
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Relabel the targets so instance = real hostname
|
|
||||||
discovery.relabel "node_exporter" {
|
|
||||||
targets = prometheus.exporter.unix.node.targets
|
|
||||||
|
|
||||||
rule {
|
|
||||||
target_label = "instance"
|
|
||||||
replacement = constants.hostname
|
|
||||||
}
|
|
||||||
|
|
||||||
rule {
|
|
||||||
target_label = "job"
|
|
||||||
replacement = "integrations/node_exporter"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Scrape the properly labeled targets
|
|
||||||
prometheus.scrape "node_exporter" {
|
|
||||||
targets = discovery.relabel.node_exporter.output
|
|
||||||
forward_to = [prometheus.remote_write.prometheus.receiver]
|
|
||||||
scrape_interval = "15s"
|
|
||||||
honor_timestamps = <%= @ay_prom_honor_timestamps %>
|
|
||||||
track_timestamps_staleness = <%= @ay_prom_track_timestamps_staleness %>
|
|
||||||
}
|
|
||||||
|
|
||||||
prometheus.remote_write "prometheus" {
|
|
||||||
external_labels = {
|
|
||||||
// makes every series from this Alloy unmistakably unique
|
|
||||||
alloy_instance = constants.hostname,
|
|
||||||
}
|
|
||||||
endpoint {
|
|
||||||
url = "<%= @ay_prom_url %>"
|
|
||||||
basic_auth {
|
|
||||||
username = "<%= @ay_loki_username %>"
|
|
||||||
password = "<%= @ay_loki_userpass %>"
|
|
||||||
}
|
|
||||||
queue_config {
|
|
||||||
max_shards = <%= @ay_prom_max_shards %>
|
|
||||||
max_samples_per_send = <%= @ay_prom_max_samples_per_send %>
|
|
||||||
batch_send_deadline = "<%= @ay_prom_batch_send_deadline %>"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
<% end %>
|
|
||||||
82
templates/config.alloy.tail.erb
Normal file
82
templates/config.alloy.tail.erb
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<% if @ay_manage_loki == true -%>
|
||||||
|
]
|
||||||
|
sync_period = "5s"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scrape the logs from the matched files
|
||||||
|
loki.source.file "system_logs" {
|
||||||
|
targets = local.file_match.system_logs.targets
|
||||||
|
forward_to = [loki.process.syslog.receiver]
|
||||||
|
}
|
||||||
|
|
||||||
|
loki.process "syslog" {
|
||||||
|
|
||||||
|
stage.static_labels {
|
||||||
|
values = {
|
||||||
|
fqdn = constants.hostname,
|
||||||
|
service = "linux_logs",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
forward_to = [loki.write.loki.receiver]
|
||||||
|
}
|
||||||
|
|
||||||
|
loki.write "loki" {
|
||||||
|
endpoint {
|
||||||
|
url = "<%= @ay_loki_url %>"
|
||||||
|
basic_auth {
|
||||||
|
username = "<%= @ay_loki_username %>"
|
||||||
|
password = "<%= @ay_loki_userpass %>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% end -%>
|
||||||
|
<% if @ay_manage_prom == true -%>
|
||||||
|
// 1. Exporter (or keep your existing node_exporter binary)
|
||||||
|
prometheus.exporter.unix "node" {
|
||||||
|
// optional: disable unused collectors
|
||||||
|
// disable_collectors = ["ipvs", "btrfs", ...]
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Relabel the targets so instance = real hostname
|
||||||
|
discovery.relabel "node_exporter" {
|
||||||
|
targets = prometheus.exporter.unix.node.targets
|
||||||
|
|
||||||
|
rule {
|
||||||
|
target_label = "instance"
|
||||||
|
replacement = constants.hostname
|
||||||
|
}
|
||||||
|
|
||||||
|
rule {
|
||||||
|
target_label = "job"
|
||||||
|
replacement = "integrations/node_exporter"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Scrape the properly labeled targets
|
||||||
|
prometheus.scrape "node_exporter" {
|
||||||
|
targets = discovery.relabel.node_exporter.output
|
||||||
|
forward_to = [prometheus.remote_write.prometheus.receiver]
|
||||||
|
scrape_interval = "15s"
|
||||||
|
honor_timestamps = <%= @ay_prom_honor_timestamps %>
|
||||||
|
track_timestamps_staleness = <%= @ay_prom_track_timestamps_staleness %>
|
||||||
|
}
|
||||||
|
|
||||||
|
prometheus.remote_write "prometheus" {
|
||||||
|
external_labels = {
|
||||||
|
// makes every series from this Alloy unmistakably unique
|
||||||
|
alloy_instance = constants.hostname,
|
||||||
|
}
|
||||||
|
endpoint {
|
||||||
|
url = "<%= @ay_prom_url %>"
|
||||||
|
basic_auth {
|
||||||
|
username = "<%= @ay_loki_username %>"
|
||||||
|
password = "<%= @ay_loki_userpass %>"
|
||||||
|
}
|
||||||
|
queue_config {
|
||||||
|
max_shards = <%= @ay_prom_max_shards %>
|
||||||
|
max_samples_per_send = <%= @ay_prom_max_samples_per_send %>
|
||||||
|
batch_send_deadline = "<%= @ay_prom_batch_send_deadline %>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
<% end -%>
|
||||||
3
templates/log_targets.alloy.erb
Normal file
3
templates/log_targets.alloy.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
<% @log_targets_array.each do |target| -%>
|
||||||
|
{__path__ = "<%= target %>"},
|
||||||
|
<% end -%>
|
||||||
Reference in New Issue
Block a user