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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d62c4ea
Fixes typo in molecule init template docs
wilmardo 038c512
Expension of the LXD driver
wilmardo cae3eff
Moves LXD create, prepare, destroy to ansible/playbooks dir
wilmardo c046ad8
Adds LXD remote options to destroy playbook
wilmardo 2394c5b
Restores default xenial image in LXD create playbook and some indent …
wilmardo 2d50359
Update the test LXD playbooks to reflect changes
wilmardo 6ed927d
Removes the jinja2 raw tags from the playbooks
wilmardo b12752e
Reduce line length <120 chars in LXD prepare.yml by using shorthand
wilmardo 9a6ed00
Adds tests for new API schema, implements source dict to be closer to…
wilmardo d307ad4
Replaces defined string with call to str()
wilmardo f9441c4
Adds config parameter to lxd create playbook
wilmardo 221fceb
Fix formatting
wilmardo 8a99924
Updates error string
wilmardo f9b0eec
Finally fixed unit tests!
wilmardo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
.../driver/lxd/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/create.yml
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...driver/lxd/{{cookiecutter.molecule_directory}}/{{cookiecutter.scenario_name}}/prepare.yml
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -710,6 +710,84 @@ def pre_validate_base_schema(env, keep_string): | |
}, | ||
} | ||
|
||
platforms_lxd_schema = { | ||
'platforms': { | ||
'type': 'list', | ||
'schema': { | ||
'type': 'dict', | ||
'schema': { | ||
'name': { | ||
'type': 'string', | ||
}, | ||
'url': { | ||
'type': 'string', | ||
}, | ||
'cert_file': { | ||
'type': 'string', | ||
}, | ||
'key_file': { | ||
'type': 'string', | ||
}, | ||
'trust_password': { | ||
'type': 'string', | ||
}, | ||
'source': { | ||
'type': 'dict', | ||
'schema': { | ||
'type': { | ||
'type': 'string', | ||
}, | ||
'mode': { | ||
'type': 'string', | ||
'allowed': [ | ||
'pull', | ||
'local', | ||
], | ||
}, | ||
'server': { | ||
'type': 'string', | ||
}, | ||
'protocol': { | ||
'type': 'string', | ||
'allowed': [ | ||
'lxd', | ||
'simplestreams', | ||
], | ||
}, | ||
'alias': { | ||
'type': 'string', | ||
}, | ||
}, | ||
}, | ||
'architecture': { | ||
'type': 'string', | ||
'allowed': [ | ||
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. Same here (source) |
||
'x86_64', | ||
'i686', | ||
], | ||
}, | ||
'config': { | ||
'type': 'dict', | ||
'allow_unknown': True, | ||
}, | ||
'devices': { | ||
'type': 'dict', | ||
'allow_unknown': True, | ||
}, | ||
'profiles': { | ||
'type': 'list', | ||
'schema': { | ||
'type': 'string' | ||
} | ||
}, | ||
'force_stop': { | ||
'type': 'boolean', | ||
}, | ||
} | ||
} | ||
}, | ||
} | ||
|
||
dependency_command_nullable_schema = { | ||
'dependency': { | ||
'type': 'dict', | ||
|
@@ -863,6 +941,8 @@ def validate(c): | |
elif c['driver']['name'] == 'vagrant': | ||
util.merge_dicts(schema, driver_vagrant_provider_section_schema) | ||
util.merge_dicts(schema, platforms_vagrant_schema) | ||
elif c['driver']['name'] == 'lxd': | ||
util.merge_dicts(schema, platforms_lxd_schema) | ||
else: | ||
util.merge_dicts(schema, platforms_base_schema) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Create | ||
hosts: localhost | ||
connection: local | ||
gather_facts: false | ||
no_log: "{{ not (lookup('env', 'MOLECULE_DEBUG') | bool or molecule_yml.provisioner.log|default(false) | bool) }}" | ||
tasks: | ||
- name: Create default source variable | ||
set_fact: | ||
default_source: | ||
type: image | ||
server: https://images.linuxcontainers.org | ||
alias: ubuntu/xenial/amd64 | ||
|
||
- name: Create molecule instance(s) | ||
lxd_container: | ||
url: "{{ item.url | default(omit) }}" | ||
cert_file: "{{ item.cert_file | default(omit) }}" | ||
key_file: "{{ item.key_file | default(omit) }}" | ||
trust_password: "{{ item.trust_password | default(omit) }}" | ||
name: "{{ item.name }}" | ||
state: started | ||
source: "{{ default_source | combine(item.source | default({})) }}" | ||
config: "{{ item.config | default(omit) }}" | ||
architecture: "{{ item.architecture | default(omit) }}" | ||
devices: "{{ item.devices | default(omit) }}" | ||
profiles: "{{ item.profiles | default(omit) }}" | ||
wait_for_ipv4_addresses: true | ||
timeout: 600 | ||
with_items: "{{ molecule_yml.platforms }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
- name: Prepare | ||
hosts: all | ||
gather_facts: false | ||
tasks: | ||
- name: Test if Python is installed | ||
raw: python -V # execute Python | ||
register: python_version | ||
changed_when: "'not found' in python_version.stderr" | ||
failed_when: false | ||
|
||
- name: Install Python when not installed | ||
raw: | | ||
if [ -x "$(command -v apt-get)" ] | ||
then | ||
apt-get update && apt-get install -y python | ||
elif [ -x "$(command -v yum)" ] | ||
then | ||
yum install -y python | ||
elif [ -x "$(command -v zypper)" ] | ||
then | ||
zypper -n --gpg-auto-import-keys refresh && zypper -n install -y python python-xml | ||
elif [ -x "$(command -v apk)" ] | ||
then | ||
apk update && apk add python | ||
elif [ -x "$(command -v pacman)" ] | ||
then | ||
pacman -Syu --noconfirm python2 | ||
elif [ -x "$(command -v dnf)" ] | ||
then | ||
dnf --assumeyes install python python-devel python2-dnf | ||
elif [ -x "$(command -v emerge)" ] | ||
then | ||
emerge --ask n dev-lang/python-2 | ||
fi | ||
when: "'not found' in python_version.stderr" | ||
|
||
- name: Gathering Facts | ||
setup: # aka gather_facts | ||
|
||
- name: Install equery on Gentoo based containers when not available | ||
raw: test -e /usr/bin/equery || emerge --ask n gentoolkit | ||
register: equery_status | ||
changed_when: equery_status.stdout != '' | ||
when: ansible_os_family == 'Gentoo' | ||
|
||
- name: Install some basic packages because LXC containers are bare | ||
package: | ||
name: | ||
- ca-certificates | ||
- curl | ||
- sudo | ||
state: present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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).