-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added modules to manage Atomic Host Platform (host and image) #1902
Conversation
Thanks @krsacme for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion. |
def main(): | ||
module = AnsibleModule( | ||
argument_spec = dict( | ||
state = dict(default=None, choices=['rollback', 'status', 'upgrade', 'rebase'], required=True), |
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.
What about support for the deploy
verb?
https://github.com/projectatomic/atomic/blob/master/docs/atomic-host.1.md
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.
Also, to properly use the rebase
verb, you'll also need to provide a refspec
argument.
# atomic host rebase --help
usage: atomic host rebase [-h] [--os OS] refspec ...
positional arguments:
refspec Origin refspec for new deployment
args Additional arguments appended to the rebase method. Use `--
--OPTION=VAL` if you want to pass additional unsupported
arguments to rpm-ostree.
optional arguments:
-h, --help show this help message and exit
--os OS Operate on provided OSNAME
I'd like to see the See the reboot options to the commands below:
|
description: | ||
- Whether to install (C(install) or C(run) or C(update)), or remove (C(stop) or C(uninstall)) | ||
required: True | ||
choices: ["install", "run", "stop", "update", "uninstall"] |
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 considered best practice that Ansible module are declarative. Refrain from verb especially in a param called state like this. Look at other similar modules (don't look at the Docker module -- that one is an anti-pattern we are going to address soon enough) and you'll see state use values like "present", "latest", "absent" if its for deployment or package management. Use "started", "restarted" and "stopped" for process management. I'd hesitate about having a module that does both deployment and service management.
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.
@tima, the atomic image management is similar to the docker, it uses pull (install), start (run). This particular utility is more of both deployment and service management. I will analyze further if it can be limited to only a particular type.
Having said, I will modify the verbs and will re-submit it.
@miabbott As you mentioned, reboot cannot be done as part of this execution, if it required, probably the playbook should be written in such a way that on successful upgrade, the next step should be reboot and that will be the end of playbook. It is appropriate to add a caution as part of the description to remind the user about this. I am just thinking loud. |
Thanks @krsacme for this PR. This PR requires revisions, either because it fails to build or by reviewer request. Please make the suggested revisions. When you are done, please comment with text 'ready_for_review' and we will put this PR back into review. [This message brought to you by your friendly Ansibull-bot.] |
ready_for_review |
Thanks @krsacme for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion. [This message brought to you by your friendly Ansibull-bot.] |
requirements: | ||
- atomic | ||
options: | ||
state: |
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.
Would you consider renaming this from state
to action
or command
?
I feel like state
does not accurately describe what is happening. Using any of deploy/rebase/rollback/upgarde is really just an action and not really a state of the system. These are more like transitions from one ostree deployment to another.
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.
Agreed @miabbott. A param called state
has specific connotations in good Ansible module design which this does not conform. You shouldn't use action
either since that is a play directive and could get confusing. I recommend command
which is commonplace for most modules like this one.
@bcoca atomic host and image modules are just commands that will be executed. For example, referring to |
ready_for_review |
version_added: "2.2" | ||
author: "Saravanan KR @krsacme" | ||
notes: | ||
- Host should be an atomic platform (verified by existence of '/run/ostree-booted' file) |
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 the case of the atomic update
command that is used below, there is no requirement that the host be an Atomic Host.
However, for the commands in the atomic_host.py
module, the host does need to be an Atomic Host.
I would suggest moving this note to the atomic_host.py
module.
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.
Moved
shipit |
1 similar comment
shipit |
rc, out, err = module.run_command(args, check_rc=False) | ||
|
||
if rc == 77 and revision == 'latest': | ||
module.exit_json(msg="Already on latest") |
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.
Should specify changed=False explicitly here.
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.
Added
I found a couple bugs and had a few questions. Made inline comments for those. needs_revision |
ready_for_review |
Thanks @krsacme for this new module. When this module receives 'shipit' comments from two community members and any 'needs_revision' comments have been resolved, we will mark for inclusion. [This message brought to you by your friendly Ansibull-bot.] |
Further probing about the requirement on python-2.6. needs_info |
All issues addressed. Merged to devel. Thanks! |
shipit |
oh, ha ... my page hadn't refreshed yet :) |
if started: | ||
args = ['atomic', 'run', image] | ||
else: | ||
args = ['atomic', 'install', 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.
Arguments-wise, IMHO, this doesn't feel very intuitive. It also assumes you can run 'install' w/o first 'uninstall' - that's entirely container-image dependent. How about making latest
into a boolean, and reflect the desired state with state
?
e.g. atomic_image: name=foo latest=true state=installed
(or uninstalled or running or something like that)
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.
@cevich Thanks for your comments. Sorry for delayed response, stuck with other issues.
There was a discussion [1] with @detiber @tima @bcoca regarding how we should name the arguments. The suggestion was to not to mix package and process management together and finally, came up with above. Please let us know if it make sense.
I just caught that this got merged. Great work @krsacme! Thanks for all of your time and persistence on this contribution. |
@krsacme See @cevich's note -- this will be in the 2.2 release so we have until early/mid september before we can't change the parameters anymore. Also -- @bcoca mentioned today that this should be categorized in cloud similar to docker and lxd. So I'll move it from system/atomic into cloud/atomic today. |
@krascme in case it wasn't apparent, if you want to make changes to address @cevich's notes, it would be a new PR. Feel free to ping me in IRC so that we can be sure to look at any backwards incompatible parameter changes before 2.2 goes out. |
@abadger thanks for consideration. Sorry I didn't get to make it before merge. |
default: null | ||
upgrade: | ||
description: | ||
- Forcefully upgrade if the container, even if the container is already running |
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/upgrade if the container/upgrade the container/
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.
@cevich You are looking at an older version, please take a look at the later revision.
ISSUE TYPE
COMPONENT NAME
atomic_host
atomic_image
ANSIBLE VERSION
SUMMARY
Atomic Host Plaform provides atomic command to manage the host and to manage the container images on the host. Details of the command can be found at [1]. Added 2 modules in here:
atomic_host :- Module to mange the host itself, upgrade or rollback
atomic_image :- Module to manage the container images
[1] http://www.projectatomic.io/docs/usr-bin-atomic/, https://github.com/projectatomic/atomic/