Welcome to the Policy as Code Forum! Get started here

The webinar will be a available on demand for a year for those who miss the opportunity. I will also be using some of the content (demos) in other communication channels as well.

1 Like

For variable use cases - see is/is not defined in ansible-policy/ansible_policy/policybook/README.md at main Ā· ansible/ansible-policy Ā· GitHub

2 Likes

If you missed todays webinar about the new ansible-policy CLI tooling never fear! Itā€™s available on demand - Automating Policy as Code for consistency and compliance

If you just want to play with the code, then checkout:
GitHub - ansible/ansible-policy: ansible-policy is a prototype implementation which allows us to define and set constraints to the Ansible project in OPA Rego language. and
GitHub - ansible/ansible-policybook-examples

^^^ Really looking forward to getting some PRs for more examples

You can also check out the recorded demo on Linkedin
Enjoy!

2 Likes

I attended the webinar from earlier today, and I must say Iā€™m much more comfortable with the direction this is taking than I was last week.

This isnā€™t really a summary of the webinar (like @gwmngilfen hoped for) as much as my impression of what I heard and saw. Furthermore, this is still early days, so how PoC eventually integrates into workflows etc. will undoubtedly evolve. So with those caveats, hereā€™s a first draft of the PoC elevator speech Iā€™ll eventually share with my team. Itā€™ll probably leave out details that @Phil_Griffiths and friends might consider crucial distinguishing deliverables, but I absorb new stuff in multiple passes, and Iā€™ve only had my first pass at any concrete details. Okay, enough qualifiers.

Imagine ā€œansible-lint for policyā€. Like ansible-lint, you can run ansible-policy on individual files (playbooks certainly; I donā€™t know about individual task files) or on a whole project. And the console output resembles that of ansible-lint. Beyond that, though, the contrasts between them helps clarify what ansible-policy is all about.

The rules of ansible-lint are implemented in python; you tweak config file(s) to choose which of those rules are in- or out-of-play and to what degree. In contrast, Policy as per ansible-policy is defined in YAML files; no python required. People who work with Ansible YAML assets should be able to read and write their own policy definitions. Individual sets of policy files can be created, shared, mixed, matched, and tweaked to fit an organizationā€™s requirements. They can be managed as sets of small files in logical subdirectories; you donā€™t have to compile or combine them into a ā€œblack box policy blobā€.

I think of ansible-policy as picking up where ansible-lint leaves off. So for example where ansible-lint encourages you to set an owner: and group: when using the ansible.builtin.template module, your locally-written policy for ansible.builtin.template could check that the values for owner: or group: come from an approved list of user and group ids. Similarly for pretty much any values in whatever context you care to specify, you can put some constraints on them. I donā€™t feel I have enough exposure to it yet to say anything more specific, but thatā€™s the perspective Iā€™ve taken away from todayā€™s webinar. See the examples at GitHub - ansible/ansible-policybook-examples for, well, examples.

It should be fun to see how well this description holds up over time as the tool and associated technology matures.

5 Likes

Thank you Todd, that clears up some confusion I had about this initially. I didnā€™t attend todayā€™s seminar, so I appreciate your write-up.

You should feed them into InstructLab and let the generative AI write some more :stuck_out_tongue:

This is the plan. Weā€™re working with IBM Research to do just that. Results are already encouraging!

Hey Todd!

Thanks for attending and the excellent write up. Right now, focussing on content creation this does very much align with an ansible-lint way of thinking. When we get into the platform functionality this will become so very much more.

Had a look at the Webinar, some thoughts.
It doesnā€™t feel like itā€™s part of the Ansibleā„¢ eco system.
There is some workflow issues with the way that you would want to implement policies, I like the idea that it can check code, but can that policy be run agains Infra?

Hi Karl.

The ā€˜grand planā€™ is to have policy content as part of the overall content ecosystem. Hopefully it can become an extension to collections.

Right now the tooling is only designed to show you the art of the possible and get feedback on use cases and policies.

The next engineering efforts are focussed around your sort of infra needs where this needs to be part of a SDL ā€˜workflowā€™ with suitable integration points. As well as the tooling, weā€™re aiming to make this an end to end experience where when creating automation content this becomes part of the flow.

Thanks for the comments!
Phil.

Thank you for the inforomation!

It helped me understand as I had wondered what the difference was between this and ansible-lint.

I just created a video on how to install ansible-policy and a simple rulebook about Policy as Code on my blog: Project Policy Validation with OPA and ansible-policy - Ansible Pilot

3 Likes

Now that I have a better understanding of what ansible-policyā€™s intended function is, I really like where itā€™s headed. It definitely will need a GitHub Action similar to the one for ansible-lint.

1 Like

Is this the correct place for customer to provide their feedback on Policy as Code? Thank you in advance for the feedback!

Yes it is! Please share your thoughts here in this thread.

My work group runs a clustered application that the vendor provides as stand-alone RPMs. You can install multiple versions side-by-side, and activate whichever one is supposed to be live. Saves a lot of time on upgrades, etc.

The part relevant to ā€œPolicy as Codeā€ is the internal discussion weā€™re currently having about how many and/or which RPMs to leave installed vs. to remove, and likewise policing our local cache of RPM files weā€™ve downloaded from the vendor. Iā€™m not sure what the final decision on this will be, but it smells a lot more like policy than procedure. That is, uninstalling installed RPMs and removing RPM files from a cache is easy. (Too easy, as weā€™ve found out. Donā€™t ask!) Choosing the right RPMs to remove would seem to me to be in the ā€œPolicy as Codeā€ wheelhouse.

Iā€™m still trying to wrap my head around how PaC intersects with automation, so specific examples like this help to clarify it. Not looking for a specific answer to this need, but rather tossing it into the idea pool to be considered as things evolve in this space.

2 Likes

We probably donā€™t want 100 examples in this single thread :slight_smile:

Weā€™ve created the policy-as-code tag (which anyone can follow for notifications), and Project Discussions seems the right venue for such discussion. So new topics in Project Discussions with that tag are the way to go.

@CindyRuss @Phil_Griffiths if itā€™s useful to you for wider circulation, you can use this link for people to create a new topic in the right way (good for docs/socials!)

https://forum.ansible.com/new-topic?title=Policy-as-code%20Topic&body=your%20feedback%20here&category=project&tags=policy-as-code

Give it a try!

Hi Todd.

The key here would be what the rule(s) would be that would dictate the conditions for any change. How do you decide when to remove/update etc?

If you are using yum/dnf to do the operations then it would probably be based around some metadata that could be used in those modules. Otherwise, youā€™d be calling to get approval or validation from some ā€˜externalā€™ system.

Have you looked at the many examples in GitHub - ansible/ansible-policybook-examples ? They should give you some ideas. Probably ansible-policybook-examples/policy/infra/os/rhel/check_pkg.yml at main Ā· ansible/ansible-policybook-examples Ā· GitHub is the base to work from for this type of example.

Phil.