-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENT-9402: Added policy to facilitate migration of ignore_interfaces.rx from inputdir to workdir (3.21.x) #2767
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -597,6 +597,47 @@ This [augments file][Augments] is a way to specify that `cf-monitord` should be | |
The following settings are defined in `controls/def.cf` can be set from an | ||
[augments file][Augments]. | ||
|
||
### Automatically migrate ignore_interfaces.rx to workdir | ||
|
||
`ignore_interfaces.rx` defines regular expressions matching network interfaces that CFEngine should ignore. | ||
|
||
Prior to `3.23.0` this file was expected to be found in | ||
`$(sys.inputdir)/ignore_interfaces.rx`. Beginning with `3.23.0` preference is | ||
given to `$(sys.workdir)/ignore_interfaces.rx` if it is found and `WARNING` is | ||
emitted by cfengine if the file is found only in `$(sys.inputdir)`. | ||
|
||
When the class `default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir` is | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the default to NOT auto migrate? Might be good to mention that as well here. |
||
defined `$(sys.workdir)/ignore_interfaces.rx` is maintained as a copy of | ||
`$(sys.inputdir)/ignore_interfaces.rx`. | ||
|
||
```json | ||
{ | ||
"classes": { | ||
"default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir": { | ||
"class_expressions": "cfengine_3_23|cfengine_3_24", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would seem most useful to define a class_expression that specified 3.23.0 and later releases right? Hmm. |
||
"comment": "Automatically migrate ignore_interfaces.rx to workdir." | ||
} | ||
} | ||
} | ||
``` | ||
|
||
Additionally, to disable reports about the presence of | ||
`$(sys.inputdir)/ignore_interfaces.rx` define the class | ||
`default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir_reports_disabled`. | ||
When this class is not defined, `cf-agent` will emit reports indicating it's | ||
craigcomstock marked this conversation as resolved.
Show resolved
Hide resolved
|
||
presence and state in relation to `$(sys.workdir)/ignore_interfaces.rx`. | ||
|
||
```json | ||
{ | ||
"classes": { | ||
"default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir_reports_disabled": { | ||
"class_expressions": "cfengine_3_23|cfengine_3_24", | ||
"comment": "We don't want reports about legacy ignore_interfaces.rx to be emitted." | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### dmidecode inventory | ||
|
||
When dmidecode is present, some key system attributes are inventoried. The | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,66 @@ bundle agent MPF_class_recommendations | |
if => "cfengine_internal_purge_policies"; | ||
} | ||
|
||
@if minimum_version(3.23.0) | ||
# The preferred location for ignore_interfaces.rx changed from | ||
# $(sys.inputdir)/ignore_interfaces.rx to $(sys.workdir)/ignore_interfaces.rx in | ||
# 3.23.0, versions lower than 3.23.0 only look for the file in inputdir and | ||
# messages relating to the preferred location change are irrelevant. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what this "and messages relating..." sentence is talking about? If the messages are irrelevant why are we keeping them? Are we keeping them? |
||
|
||
bundle agent ignore_interfaces_rx_reccomendations | ||
# @brief Recommend completing migration of ignore_interfaces.rx from inputdir to workdir | ||
# | ||
# @description This bundle identifies the presence of ignore_interfaces.rx in | ||
# inputdir and emits messages about its presence. Additionally, the file is | ||
# automatically copied if the file is present in inputdir and the class | ||
# default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir is defined (not | ||
# defined by default). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there we go, it is not defined by default, which is what I assumed but I think you should explicitly state that in the md file above. |
||
{ | ||
meta: | ||
"tags" slist => { "cfengine_recommends" }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what impact does this have? Do we use this somewhere or have used it previously? Interesting, just in this file I guess. @nickanderson was there a plan to leverage this tag somehow? More curious than anything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While testing last night I found that it wasn't working, it was searching for the wrong tag. So, it should have been used but was not. |
||
|
||
classes: | ||
"ignore_interfaces_in_workdir" -> { "ENT-9402" } | ||
if => fileexists( "$(sys.workdir)/ignore_interfaces.rx" ); | ||
|
||
"ignore_interfaces_in_inputdir" -> { "ENT-9402" } | ||
if => fileexists( "$(sys.inputdir)/ignore_interfaces.rx" ); | ||
|
||
files: | ||
default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir.ignore_interfaces_in_inputdir:: | ||
"$(sys.workdir)/ignore_interfaces.rx" -> { "ENT-9402" } | ||
copy_from => local_dcp( "$(sys.inputdir)/ignore_interfaces.rx"), | ||
comment => concat( "Excluding interfaces should be done outside of the", | ||
" policy input directory so that it's easier to", | ||
" ignore different interfaces on different hosts."); | ||
|
||
default:cfengine_3:: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why cfengine_3 here? Is ignore_interfaces.rx only in version >=3? Not that we do much with version <3. |
||
"$(sys.inputdir)/ignore_interfaces.rx" -> { "ENT-9402" } | ||
delete => tidy, | ||
action => policy( "warn" ), | ||
comment => concat( "Excluding interfaces should be done outside of the", | ||
" policy input directory so that it's easier to", | ||
" ignore different interfaces on different hosts.", | ||
" This file should be deleted once it's been migrated", | ||
" to sys.workdir"); | ||
|
||
reports: | ||
|
||
ignore_interfaces_in_inputdir.!default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir_reports_disabled:: | ||
"NOTICE: 'ignore_interfaces.rx' is present in '$(const.dollar)(sys.inputdir)' ('$(sys.inputdir)/ignore_interfaces.rx'). We recommend that it be removed and migrated to '$(const.dollar)(sys.workdir)' ('$(sys.workdir)/ignore_interfaces.rx')" | ||
if => not( fileexists( "$(sys.workdir)/ignore_interfaces.rx" ) ); | ||
|
||
(ignore_interfaces_in_workdir.ignore_interfaces_in_inputdir).!default:mpf_auto_migrate_ignore_interfaces_rx_to_workdir_reports_disabled:: | ||
"NOTICE: 'ignore_interfaces.rx' identical in '$(const.dollar)(sys.workdir)' and '$(const.dollar)(sys.inputdir)'. We recommend removing '$(const.dollar)(sys.inputdir)/ignore_interfaces.rx'" | ||
if => strcmp( readfile( "$(sys.workdir)/ignore_interfaces.rx"), | ||
readfile( "$(sys.inputdir)/ignore_interfaces.rx") ); | ||
|
||
"NOTICE: 'ignore_interfaces.rx' in '$(const.dollar)(sys.workdir)' and '$(const.dollar)(sys.inputdir)' but not identical. We recommend verifying the desired content of '$(const.dollar)(sys.workdir)/ignore_interfaces.rx', correcting it if necessary and removing '$(const.dollar)(sys.inputdir)/ignore_interfaces.rx'" | ||
if => not( strcmp( readfile( "$(sys.workdir)/ignore_interfaces.rx"), | ||
readfile( "$(sys.inputdir)/ignore_interfaces.rx") ) ); | ||
|
||
} | ||
@endif | ||
|
||
bundle agent postgresql_conf_recommendations | ||
# @brief Recommendations about the configuration of postgresql.conf for CFEngine Enterprise Hubs | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, seeing the policy below I see that it is both a
WARNING
and a report. Maybe mention the report here as well?