One more implementation question.
It's pretty clear that we are going to have a different type of setup here. I respect that. Rather than have every user input all the switches to override the defaults every time, we'd like to have them automatically default to ones that are most common here.
Besides the few environment vars that have been pointed out to me here, how and where do I set them? I see them in constants. Are they really constants (can't/shouldn't be changed) or are they defaults? If the latter, how should they be set to suit a particular environment?
<tim/>
constants.py is part of the source code, but a few can be overridden by environment variables or command line flags, yes.
you should never edit constants.py:
https://github.com/ansible/ansible/blob/devel/lib/ansible/constants.py
but you can easily set all the ANSIBLE_FOO variables in your bash profile, etc, or use bash aliases
It is probably a good idea to make various other things settable via the environment too (like the timeout, etc).
Saves writing wrapper scripts or setting aliases when you don’t want to do that.
Hopefully that answers the question.
Hopefully that answers the question.
It does. I can work up a patch for that.
Anyone have specific vars to include/exclude here?
<tim/>
Great.
I’d say add optional env variables for all of them, following the same pattern as the others.
I already forked the devel branch and made changes in a branch of my own. I didn't create such a mechanism for the two passwords or the private key constants. That didn't seem like a good idea to me, but I'm open to changing that if I'm mistaken.
I also left connection and connection_opts as is for now to discuss the later -- the value is a list. How should a list get represented? Comma delimited? Space? Colon? All the above? It occurred to me why you might want to add a plugin folder under connection now do opts can be implicitly determined rather than explicitly.
<tim/>
I already forked the devel branch and made changes in a branch of my own. I didn’t create such a mechanism for the two passwords or the private key constants. That didn’t seem like a good idea to me, but I’m open to changing that if I’m mistaken.
The key file could be useful, agreed on passwords.
I also left connection and connection_opts as is for now to discuss the later – the value is a list. How should a list get represented? Comma delimited? Space? Colon? All the above? It occurred to me why you might want to add a plugin folder under connection now do opts can be implicitly determined rather than explicitly.
A variable like ANSIBLE_CONNECTION is reasonable.
The list is actually just the list of all possible valid connection types, so that shouldn’t be user specifiable anyway.
The key file could be useful, agreed on passwords.
OK. I will add that in to my code before I issue a pull.
A variable like ANSIBLE_CONNECTION is reasonable.
Likewise.
The list is actually just the list of all possible valid connection types, so that shouldn’t be user specifiable anyway.
OK, but what does a developer like myself or Darren do when we develop our own connectors to support something other than sudo? Is this where scanning anything under connector plugins would need to happen?
OK, but what does a developer like myself or Darren do when we develop our own connectors to support something other than sudo? Is this where scanning anything under connector plugins would need to happen?
Depending on complexity (assuming it just inherits from the others), we could just incorporate it into ansible proper.
If we want to make things look in an (additional) plugins directory, that’s fine, though the core ones should always be imported.
Realizing I didn’t answer the right question.
That list is fed to the opt parse module IIRC as a list of valid choices. If the plugins are made more plugin-ey, they would just have a name, and it would raise an error if a plugin didn’t exist of that name.
In other words, yes, this variable has to go away.
–Michael
Having gotten my more environmental variable defaults in the pull request queue, I was starting to take a first crack at making connections pluggable.
I was looking to handle loading any additional connections in the connection init where the local and paramiko are imported and instaniated. There is one snag though. Each transport has its own connection class. The local transport instanitates LocalConnection, the paramiko transport instaniates ParamikoConnection. So I can import a connection class, but I don’t really know what class to instantiate in there without addition input. So what to do?
Convention over configuration is preferable to me, but I’m not sure what is the best way to implement that. Uppercase the first letter and append Connection?
Thoughts?
typically in those cases I define a top-level factory method in the module like so, where every module has the same method defined:
def create(parameters):
return new FooClass(parameters)
class FooClass(object):
… stuff …
Sounds good. Skip that level of abstraction in core classes?
Relatedly, shouldn’t all connection classes inherit from a base connection class rather than object?
Sounds good. Skip that level of abstraction in core classes?
Skip that in non-plugin classes? Yes.
Relatedly, shouldn’t all connection classes inherit from a base connection class rather than object?
It’s kind of unnecessary.
Duck typing versus interfaces.