Ignored_environments.yml

Hello!

I'm using Foreman with puppet and is looking into using Roles and Profiles
for puppet.

So I want to filter out classes… And I can't get it to work.

I'm using the exact filter as in:
https://theforeman.org/manuals/1.14/#4.2.2Classes
(To filter out everything except role::).

I already got this environment that has imported a lot of classes.
I create the file /usr/share/foreman/config/ignored_environments.yml
(ubuntu) and inserts the :filters: found in documentation.

After a restart of apache (service apache2 restart) I went to
Configure/Classes. Removed a Class I don't want to import and clicked
'import environments'.

What I get is that it is asking me to import my deleted class.

What I expected was not to import my deleted class. (Ie. not show up in
import)

When looking into this I found this Issue.
http://projects.theforeman.org/issues/12161
It sure looks just like my problem.

What am I doing wrong?

Heya!

That issue is what lead to that entry being placed in the manual, so
they're effectively the same thing.

Can you share the exact contents of your ignored_environments.yml, just so
we can see? Maybe there's a typo or something on another line that is
causing issues…

> Heya!
Hi! Thanks for contacting.
>
> That issue is what lead to that entry being placed in the manual, so
> they're effectively the same thing.
>
> Can you share the exact contents of your ignored_environments.yml,
> just so we can see? Maybe there's a typo or something on another line
> that is causing issues…
No problem. My file is:
------- top of file -------
#:ignored:

- test

:filters:

  • !ruby/regexp '/^(?!role::.*)$/'
    ------- bottom of file -------

The "—" is of course not part of the file. This should be a
copy-and-paste directly from the documentation.

Not long ago (sorry for not replying earlier) I noticed that I coult get
it to work by adding a .* to the end of the rule just before the $.
The documentation also states that "It will not delete any environments
or classes already in Foreman." which is false. After adding the rule
(with the ending .*) it asked if I wanted to delete any of the ignored
classes.

··· Den 2017-09-05 kl. 12:14, skrev Greg Sutcliffe:

>
> No problem. My file is:
> ------- top of file -------
> #:ignored:
> # - test
>
> :filters:
> - !ruby/regexp '/^(?!role::.*)$/'
> ------- bottom of file -------
>
> The "—" is of course not part of the file. This should be a
> copy-and-paste directly from the documentation.

Yeah, that looks fine. YAML is annoyingly special about whitespace, but
that indentation looks ok too.

> Not long ago (sorry for not replying earlier) I noticed that I coult
> get it to work by adding a .* to the end of the rule just before the
> $.

So to be clear, (?!role::.) doesn't work, but (?!role::). does work?
I see the same behaviour on Rubular.com, although I haven't tested it
locally yet. Would you be prepared to send a small patch to the docs?

> The documentation also states that "It will not delete any
> environments or classes already in Foreman." which is false. After
> adding the rule (with the ending .*) it asked if I wanted to delete
> any of the ignored classes.

True, I guess this doc predates when we added the import page offering
to remove unfound items - although the removal is unchecked by default,
I think. Again, a patch to the docs (or just an issue logged in our
issue tracker) would be awesome.

Thanks!
Greg

··· On Tue, 2017-09-05 at 20:55 +0200, Roger Mårtensson wrote: