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
Expand LXD driver functionality #1436
Conversation
@@ -1,11 +0,0 @@ | |||
--- |
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.
Why was this removed? Seemed like a good file to help users bootstrap the default image lxd was using. IIRC python didn't ship with that image.
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.
It is replaced by the expanded molecule/provisioner/ansible/playbooks/lxd/prepare.yml
as seen a bit further below.
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.
Oh, I see I had missed that. The prepare you created is similar to our Dockerfile setup where we ensure the docker container has the necessary dependencies. 👍
molecule/driver/lxd.py
Outdated
server: https://images.linuxcontainers.org | ||
alias: ubuntu/xenial/amd64 | ||
profiles: | ||
- default |
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.
Since you have implemented this API for molecule.yml we need to validate the schema. Can you update the v2 schema similar to what we did with dockder and vagrant.
https://github.com/metacloud/molecule/blob/master/molecule/model/schema_v2.py#L596
https://github.com/metacloud/molecule/blob/master/molecule/model/schema_v2.py#L862
And we will need to update tests with working and failing tests:
https://github.com/metacloud/molecule/blob/master/test/unit/model/v2/test_platforms_section.py
… lxd_container implementation
Looked into this with help of your comment, I think I implemented it all. Most if it was similar to the vagrant|docker implementation, only the devices argument which has a nested dict where the keys can differ was difficult. See the lxd API docs and the lxd devices docs
Had some inspiration and moved the source options to a dict with some help of Jinja2. This is the same as the lxd_container module and keeps things more easy for the end user. The part about breaking backward compatibility was not true since there was no variables before (used a custom create.yml myself, that got me confused). @retr0h Ready for review again! |
}, | ||
'protocol': { | ||
'type': 'string', | ||
'allowed': [ |
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.
I made the schema as specific as possible, these are the only values valid for the LXD api. There are now allowed values (source).
}, | ||
'architecture': { | ||
'type': 'string', | ||
'allowed': [ |
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.
Same here (source)
molecule/model/schema_v2.py
Outdated
'i686', | ||
], | ||
}, | ||
'devices': { |
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.
Please take a good look at the devices schema, that is the one I struggled with since I am not familiar with the markup. Might be not 100% correct
Is there a reason why there is a |
@retr0h Do you know when you have time to review the latest changes? In no means I want to rush you, just curious if everything is alright now :) |
@wilmardo the model unit tests are failing. |
Also, run |
@wilmardo v2 model unit tests still failing
|
@retr0h Yeah sadly I know, I struggled with it yesterday but there seems to be an issue on my own laptop since the master branch is failing too. Hopefully this evening I have time to retry on my desktop on which I know it worked before. |
I suggest just running py.test.
You can then see which test failed. |
Fixed the unit tests! Pytest helped a lot, I will try to create a PR for some more documentation about testing. Thanks for the pointers! |
As a result of direction in the following comment: > ansible#1458 (comment) And the good work and lead of ansible#1436 in: > ansible#1436
Merging. @wilmardo is our resident LXD driver community member. |
As the title states I expanded the LXD driver. The default Docker driver doesn't cut it for me because of the missing systemd. Took a try with gdraheim/docker-systemctl-replacement but it comes short sometimes, not suitable for stable testing.
What has changed:
profiles
defaults to the default profile when not provided(source) therefore now standard omittedprovisioner/ansible/playbooks
directoryTesting done:
tox -e py27-ansible26-functional -- -k lxd -v
which passed successfullyTwo points for discussion:
source
is a dict in the lxd_container module but not in molecule. I thought about changing this but it would break backwards compatibility since alias moves into this dict