Puppet (err): Found 1 dependency cycle + cycles.dot file - puppet

I am running this cmd:
puppet apply --environment split4 -l C:\Puppet_logs\log.log C:\ProgramData\PuppetLabs\code\environments\split4\manifests\bl.pp
This is the code which is running:
service {
$name :
ensure => stopped,
enable => true;
} ->
tidy { $bl_deployment_folder :
rmdirs => true,
recurse => 1,
# notify => Service[$name],
matches => ['*.dll','*.jar','*.exe','*.test','*.utd'];
# subscribe => File[$bl_deployment_folder];
} ->
file {
#set the BL run time folder and update it according to the source folder
$bl_deployment_folder :
ensure => directory,
source => $bl_source_folder,
recurse => true,
ignore => "AlisConfig.ini";
}
According to this code, I would like to:
Stop the tomcat service
Clean the specific files that I mentioned
copy files from source to my directory ($bl_deployment_folder)
Unfortunately, when I'm running it, it throws this error:
+0300 Puppet (err): Found 1 dependency cycle:
(File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll] => Tidy[\\my-server\C$\BL\ALIS_PUPPET] => File[\\my-server\C$\BL\ALIS_PUPPET] => File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll])
Cycle graph written to C:/ProgramData/PuppetLabs/puppet/cache/state/graphs/cycles.dot.
Puppet (err): Failed to apply catalog: One or more resource dependency cycles detected in graph
The circles.dot file is attached:
digraph Resource_Cycles { label = "Resource Cycles" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]"
-> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/obj_data_client.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]"
-> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/obj_data_policy.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]"
-> "File[//my-server/C$/BL/ALIS_PUPPET/obj_exceptions.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/obj_metadata.dll]"
-> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/obj_metadata_product.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]"
"File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/obj_services.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]"
-> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/objects.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]"
-> "File[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[//my-server/C$/BL/ALIS_PUPPET/xerces-c_2_6.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" "File[//my-server/C$/BL/ALIS_PUPPET/AAppData.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" -> "File[\\my-server\C$\BL\ALIS_PUPPET]"
-> "File[//my-server/C$/BL/ALIS_PUPPET/xmltools.dll]" -> "Tidy[\\my-server\C$\BL\ALIS_PUPPET]" }
What do I need to do to fix this problem?
I appreciate your help!
Thanks!

The problem here is that the tidy resource deletes files by creating file resources in $bl_deployment_folder. Each of those file resources will autorequire its parent directory file resource, in this case $bl_deployment_folder. The -> between the tidy and the directory file implies that $bl_deployment_folder requires the tidy file resources in it, and so you have a cycle.
Unfortunately, the upshot is that you can't have a file require a tidy on the same directory.
In this case, I'd suggest just removing the dependency and letting the tidy run in its own time.
I'd also note that this Puppet manifest feels very procedural. Puppet is really, really bad at "do this, then this, then that" type scripts. It wants to operate in a declarative "tell me what the final state is, and I'll sort it out" way. Trying to use it procedurally is just painful and isn't to be recommended.

Related

Join 2 measurements with InfluxDB (Flux) Version 2.6+ don't find and merge results

Working with InfluxDB is new for me. My problem is I have two measurements (StopCause and MachineState). Both have some objects inside. I wanna join from MachineState to StopCause with join.left. I check the timestamp (Flux's standard _timeobject). But the result gives me not the "relation object" (so to say) what I hope to see.
First the sturctures of the objects:
StopCause
{
_start: '2023-02-09T10:00:00Z',
_stop: '2023-02-09T13:00:00Z',
_time: '2023-02-09T11:00:00Z',
_value: 100002,
_field: 'stopCauseId',
_measurement: 'StopCause',
eventId: '"267e2cab-fd2d-4684-a5fc-7792368115b3"',
machine: '5000002_dev'
},
MachineState
{
_start: '2023-02-09T10:00:00Z',
_stop: '2023-02-09T13:00:00Z',
_time: '2023-02-09T11:00:00Z',
_value: 1,
_field: 'state',
_measurement: 'MachineState',
machine: '5000002_dev'
},
You see the _time object is absolutely the same. I insert data with manually set the timestamp.
Here is the query:
*Note: I working with NodeJS and the official #influxdata/influxdb-client package. The ${VALUE} things are Javascript variables.
${dateFrom.toISOString()} = 2023-02-09T10:00:00Z
${dateTo.toISOString()} = 2023-02-09T13:00:00Z
${externalAssetId} = 5000002_dev
import "join"
import "contrib/tomhollingworth/events"
t1 = from(bucket: "Downtime_OEE")
|> range(start: ${dateFrom.toISOString()}, stop: ${dateTo.toISOString()})
|> filter(fn: (r) => r["_measurement"] == "MachineState")
|> filter(fn: (r) => r["machine"] == "${externalAssetId}")
|> group(columns: ["_time"])
t2 = from(bucket: "Downtime_OEE")
|> range(start: ${dateFrom.toISOString()}, stop: ${dateTo.toISOString()})
|> filter(fn: (r) => r["_measurement"] == "StopCause")
|> filter(fn: (r) => r["machine"] == "${externalAssetId}")
|> pivot(rowKey:["_time","eventId","machine"], columnKey: ["_field"], valueColumn: "_value")
join.left(
left: t1,
right: t2,
on: (l, r) => l._time == r._time,
as: (l, r) => {
id = if exists r.eventId then r.eventId else "Nothing"
return {_time: l._time, otime: r._time, start: l._start, eventId: id}},
)
What I expect to have:
{
result: '_result',
table: 1,
_time: '2023-02-09T11:00:00Z',
eventId: 'xyz-123456',
otime: '2023-02-09T11:00:00Z',
start: '2023-02-09T10:00:00Z'
}
What I get:
{
result: '_result',
table: 1,
_time: '2023-02-09T11:00:00Z',
eventId: 'Nothing',
otime: '2023-02-09T11:00:00Z',
start: '2023-02-09T10:00:00Z'
}
So... how do I join correctly to get the eventId?

Suave App Hosted on IIS with HttpPlatformHandler Closes Connection

I'm trying to get a basic Suave application running in IIS (IIS 10.0) using HttpPlatformHandler (version 1.2).
When I have it return a single WebPart such as
(OK "Hello World")
The application runs in IIS fine and I can make requests to it by name at http://localhost/testapp (testapp is the name of the application under the Default Web Site).
However, if I use something more complex for the WebPart such as
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
The website starts up but I cannot reach it by application name. I am still able to reach it by port however.
When I hit the application by name I receive an HTTP 503.2 (bad gateway) response.
The application is started from a FAKE script executed by the HttpPlatformHandler.
For context, this is the FAKE script which starts the application:
#r "./tools/FakeLib.dll"
#r "Suave.dll"
open System
open Suave
open Suave.Successful
open Fake
open System.Net
open Suave.Filters
open Suave.Sockets
open Suave.Operators
open System.IO
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let port = Sockets.Port.Parse <| getBuildParamOrDefault "port" "8083"
let serverConfig =
{ defaultConfig with
logger = Logging.Loggers.saneDefaultsFor Logging.LogLevel.Verbose
bindings = [ HttpBinding.mk HTTP IPAddress.Loopback port ]
}
let app =
choose
[ GET >=> choose
[ path "/hello" >=> OK "Hello GET"
path "/goodbye" >=> OK "Good bye GET" ]
POST >=> choose
[ path "/hello" >=> OK "Hello POST"
path "/goodbye" >=> OK "Good bye POST" ] ]
startWebServer serverConfig (OK "Hello")
//startWebServer serverConfig app
The above script works as expected. However if I use the app WebPart instead of (OK "Hello") I encounter the issue described above.
For completeness here is the web.config set up for the HttpPlatformHandler:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<remove name="httpplatformhandler" />
<add name="httpplatformhandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" />
</handlers>
<httpPlatform
stdoutLogEnabled="true" startupTimeLimit="20"
processPath=".\tools\FAKE.exe"
arguments=".\test.fsx port=%HTTP_PLATFORM_PORT%" >
<environmentVariables>
</environmentVariables>
</httpPlatform>
</system.webServer>
</configuration>
I've reviewed the logs, but unfortunately I can't see anything that indicates an error.
I've checked the Event Viewer, and the only clue that something might be wrong is this information event in the application log:
The description for Event ID 1001 from source HttpPlatformHandler cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.
Here is a portion of the log from the case where the app does run as expected (without choose):
[V] 2016-01-19T02:43:40.6932823Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:43:40.7114149Z: listener started in 20.885 ms with binding 127.0.0.1:18450 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:43:40.8146603Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:43:40.8166665Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8217965Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.8228181Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8378128Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8498033Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8776578Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:40.8866594Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.8886553Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:40.9057610Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:43:40.9057610Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2531307Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:43:45.2541141Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:43:45.2541141Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:43:45.2551164Z: 'Connection: keep-alive' recurse [Suave.Web.httpLoop.loop]
And here is a portion of the log where the app does not work as expected (with routing via choose):
[V] 2016-01-19T02:44:59.6356127Z: initialising BufferManager with 827392 bytes [Suave.Socket.BufferManager]
[I] 2016-01-19T02:44:59.6537478Z: listener started in 20.987 ms with binding 127.0.0.1:18708 [Suave.Tcp.tcpIpServer]
[V] 2016-01-19T02:44:59.8848907Z: 127.0.0.1 connected, total: 1 clients [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.8879891Z: reserving buffer: 811008, free count: 99 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.8929862Z: -> processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.8939749Z: reading first line of request [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9068548Z: reserving buffer: 802816, free count: 98 [Suave.Web.readMoreData] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9209857Z: reading headers [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9259688Z: freeing buffer: 802816, free count: 99 [Suave.Web.split] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9338521Z: parsing post data [Suave.Web.processRequest]
[V] 2016-01-19T02:44:59.9378580Z: <- processor [Suave.Web.httpLoop.loop]
[V] 2016-01-19T02:44:59.9518518Z: freeing buffer: 811008, free count: 100 [Suave.Tcp.job] [Suave.Socket.BufferManager]
[V] 2016-01-19T02:44:59.9518518Z: Shutting down transport. [Suave.Tcp.job]
[V] 2016-01-19T02:44:59.9528516Z: 127.0.0.1 disconnected, total: 0 clients [Suave.Tcp.job]
When the app executes the connection opens and then closes immediately. When I hit the app by port a new connection opens and then closes immediately (again).
Am I doing something wrong with the host configuration for the app, or am I missing something in how I'm using the choose function? Any help would be appreciated. Thank you!
I think the routes should look like :
path "/app/hello"

Puppet. Using define with 2 variables

I have config file /home/ipeacocks/Dropbox/nscd/nscd.conf:
$ cat home/ipeacocks/Dropbox/nscd/nscd.conf
logfile /var/log/nscd.log
threads 4
max-threads 32
server-user nobody
stat-user somebody
debug-level 0
reload-count 5
paranoia no
restart-interval 3600
With puppet I want to change 2 lines:
server-user nobody
paranoia no
To these lines:
server-user nscd
paranoia yes
So for changing one first line I can use such manifest:
include nscd
class nscd {
define line_replace ($line, $match) {
file_line {'some useful info':
path => '/home/ipeacocks/Dropbox/nscd/nscd.conf',
line => $line,
match => $match
}
}
anchor{'nscd::begin':}
->
package { 'nscd':
ensure => installed,
}
->
line_replace {'test':
line => "server-user nscd",
match => "^\s*server-user.*$"
}
->
service { 'nscd':
ensure => running,
enable => "true",
}
->
anchor{'nscd::end':}
}
Puppet launch:
» sudo puppet apply /home/ipeacocks/Dropbox/nscd/nscd.pp
Notice: Compiled catalog for softserve-pc.ddns.softservecom.com in environment production in 0.37 seconds
Notice: /Stage[main]/Nscd/Nscd::Line_replace[test]/File_line[some useful info]/ensure: created
Notice: Finished catalog run in 0.22 seconds
But cant when 2 lines (using declared function twice):
include nscd
class nscd {
define line_replace ($line, $match) {
file_line {'some useful info':
path => '/home/ipeacocks/Dropbox/nscd/nscd.conf',
line => $line,
match => $match
}
}
anchor{'nscd::begin':}
->
package { 'nscd':
ensure => installed,
}
->
line_replace {'test':
line => "server-user nscd",
match => "^\s*server-user.*$"
}
->
line_replace {'test2':
line => "paranoia yes",
match => "^\s*paranoia.*$"
}
->
service { 'nscd':
ensure => running,
enable => "true",
}
->
anchor{'nscd::end':}
}
Launching again:
» sudo puppet apply /home/ipeacocks/Dropbox/nscd/nscd.pp 1 ↵
Error: Duplicate declaration: File_line[some useful info] is already declared in file /home/ipeacocks/Dropbox/nscd/nscd.pp:10; cannot redeclare at /home/ipeacocks/Dropbox/nscd/nscd.pp:10 on node softserve-pc.ddns.softservecom.com
Error: Duplicate declaration: File_line[some useful info] is already declared in file /home/ipeacocks/Dropbox/nscd/nscd.pp:10; cannot redeclare at /home/ipeacocks/Dropbox/nscd/nscd.pp:10 on node softserve-pc.ddns.softservecom.com
What can be wrong? Is it possible to pass two pairs of vars to declared function at once (with arrays or like that)?
I have tried this solution but it doesn't work for me:
https://stackoverflow.com/a/19034077/2971192
Change the 'some useful info' to $name in file_line -
define line_replace ($line, $match) {
file_line {$name:
path => '/home/ipeacocks/Dropbox/nscd/nscd.conf',
line => $line,
match => $match
}
}
The problem you are facing is because the second call to line_replace causes call to file_line with resource name 'some useful info' which is already declared.
Replace your define with this:
define line_replace ($line, $match) {
file_line {$name:
path => '/home/ipeacocks/Dropbox/nscd/nscd.conf',
line => $line,
match => $match
}
}
I changes the file_line resource name from a constant to the $name parameter of your define.

Only classes can set 'stage'; normal resources like XXX cannot change run stage

I have a manifest where a package depends on an apt::source resource. I've tried to make sure the apt::source runs first by setting a stage:
include apt
stage { 'first':
before => Stage['main']
}
apt::source { 'erlang_repo':
location => 'http://packages.erlang-solutions.com/ubuntu',
repos => 'contrib',
key => 'A14F4FCA',
stage => first
}
package { 'erlang':
ensure => '1:17.3'
}
However, I'm hitting the following error:
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage at /tmp/manifests/default.pp:12 on node vagrant-ubuntu-trusty-64.home
==> default: Wrapped exception:
==> default: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Only classes can set 'stage'; normal resources like Apt::Source[erlang_repo] cannot change run stage at /tmp/manifests/default.pp:12 on node vagrant-ubuntu-trusty-64.home
Any pointers will be appreciated.
If you really want to use stages, you should wrap the appropriate resources in (possibly dedicated) classes.
class site::apt_sources {
apt::source { ... }
}
and declare it like
class { 'site::apt_sources': stage => first }
Please note that the use of stages is discouraged.
If you don't use virtual resources, you can probably achieve the desired effect through this relationship instead:
Apt::Source<| |> -> Package<| |>
I decided to go with this in the end:
include apt
Apt::Pin <| |> -> Package <| |>
Apt::Source <| |> -> Package <| |>
apt::source { 'erlang_repo':
location => 'http://packages.erlang-solutions.com/ubuntu',
repos => 'contrib',
key => 'A14F4FCA'
}
package { 'erlang':
ensure => '1:17.3',
}

Puppet Exec what "<| |>" means?

I'm learning puppet language and noticed one very intriguing line of code: Exec["apt-update"] -> Package <| |> on following context:
class manifest::module {
exec { "apt-update":
command => "/usr/bin/apt-get -y update",
timeout => 3600;
}
package {
["alien", "bc", "libaio1", "unixodbc", "unzip", "rlwrap"]:
ensure => installed;
}
Exec["apt-update"] -> Package <| |>
}
Why Exec is followed by the ->? And most important, what's the meaning of <| |> ???
This expression essentially instructs Puppet to have any package resource require the "apt-update" exec resource. In other words Puppet will be sure to execute apt-get update before installing/purging/... a package.
It matches any package, see http://docs.puppetlabs.com/puppet/latest/reference/lang_collectors.html for more details

Resources