| CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 24.2k
New module: ezjail - manage FreeBSD jails with ezjail #35111
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
Conversation
|
@AugustusKling @ColOfAbRiX @DavidWittman @EvanK @LinusU @abulimov @adejoux @agaffney @ahtik @Akasurde @azaghal @dankeder @davixx @dougluce @dsummersl @giovannisciortino @goozbach @groks @haad @hryamzik @indrajitr @jasperla @jhoekx @jsumners @jtyr @kairoaraujo @kevensen @lberruti @matze @mcv21 @molekuul @mpdehaan @mulby @natefoo @nibalizer @ovcharenko @pilou- @pmarkham @pyykkis @risaacson @rosmo @saito-hideki @sebastiendarocha @sfromm @tdtrask @tmshn @xen0l As a maintainer of a module in the same namespace this new module has been submitted to, your vote counts for shipits. Please review this module and add |
pilou-
left a comment
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.
Did you consider adding integration tests ? A FreeBSD instance is available for integration tests. Here are some integration tests which use FreeBSD:
lib/ansible/modules/system/ezjail.py
Outdated
| if running. C(restarted) also creates the jail if not present | ||
| and starts or restarts it. C(absent) will delete the jail if | ||
| present (Caution This will also wipe the jailroot. Consider | ||
| stopping and disbaling the jail if you want to keep the jailroot.) |
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.
s/disbaling/disabling/
lib/ansible/modules/system/ezjail.py
Outdated
| ''' execute ezjail-admin command ''' | ||
|
|
||
| cmd = module.get_bin_path('ezjail-admin', required=True) | ||
| return module.run_command(' '.join([cmd] + list(params))) |
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.
check_rc=True parameter of run_command could be used instead of raising FailedException when rc != 0. This will allow to remove caller checks on rc and fail_json will be called automatically.
| try: | ||
| conf_file = open(filename, 'r') | ||
| for line in conf_file: | ||
| if re.search( |
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.
Just to let you know, max line length for Ansible project is 160.
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.
Ok, thanks. I don't expect lines much larger as 100. In my tests max. length was about 50.
| line = line.replace( | ||
| '"' + old_ip_addr + '"', | ||
| '"' + ip_addr + '"') | ||
| print(line) |
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.
Debug print statement must be removed
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.
In this case print is no debug statement but actually writes the content of the file. Removing it would result in an empty file.
lib/ansible/modules/system/ezjail.py
Outdated
| if new_jail: | ||
| change_msgs.append('created') | ||
| if not module.check_mode: | ||
| if 'ip_addr' not in module.params or module.params['ip_addr'] is None: |
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.
'ip_addr' not in module.params is always False
several bug fixes code improvements added integration tests
|
The test |
avoid jinja2 filters in test asserts to be more complaint with ansible interation test rules
|
@pilou- I added some tests to cover the basic functionality and most of the possible states. Shippable reports no tests run under the freebsd environments but tests run under the other environment. Not sure if this is the way it should be. I tried to guess as good as possible how the aliases file should look like (due to incomplete documentation of this part of testing and no FreeBSD only examples). Hope this is about what you expected. |
|
The test |
|
The test |
|
@AugustusKling @ColOfAbRiX @DavidWittman @EvanK @LinusU @abulimov @adejoux @agaffney @ahtik @Akasurde @azaghal @dankeder @davixx @dougluce @dsummersl @giovannisciortino @goozbach @groks @haad @hryamzik @indrajitr @jasperla @jhoekx @jsumners @jtyr @kairoaraujo @kevensen @lberruti @matze @mcv21 @molekuul @mpdehaan @mulby @natefoo @nibalizer @ovcharenko @pilou- @pmarkham @pyykkis @risaacson @rosmo @saito-hideki @sebastiendarocha @sfromm @tdtrask @tmshn @xen0l I give up on guessing how the tests work and why shippable freebsd always says "WARNING: All targets skipped.". Any help appreciated. But I have no time for guessing and reverse engineering any more. |
|
cc @mattclay - advisement on FreeBSD integration testing? |
|
@hc42 The tests appear to be running just fine: https://app.shippable.com/github/ansible/ansible/runs/56865/51/console I'm guessing you were looking at the results for the group 1 or 2 tests, but the tests you've added are configured to run in group 3: https://github.com/ansible/ansible/pull/35111/files#diff-382c42586126ab33afd08a700b0e81d3R1 |
|
Any updates on this? What is missing to get it merged? |
| @@ -0,0 +1,3 @@ | |||
| posix/ci/group3 | |||
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.
The CI groups have changed since this PR was created:
| posix/ci/group3 | |
| shippable/posix/group3 |
|
Please submit a new module request to https://github.com/ansible-collections/community.general. Thanks for your contribution. |
SUMMARY
I created this module to be able to define the state of an FreeBSD jail, managed with Ezjail, in a playbook or role. The module should only do the minimal work of creating or deleting and starting or stopping a jail (similar to the service module). This enables me to quickly setup jails for applications. The installation and configuration of the jailhost should be done by in a playbook since this differs as different people have different preferences and different use cases. This module should be as general as possible.
See https://github.com/hc42/ansible-ezjail for a test playbook. There is also a vagrant file to setup a FreeBSD VM and test the playbook on it.
ISSUE TYPE
COMPONENT NAME
new module: ezjail (system)
ANSIBLE VERSION