Re: [ansible-devel] Need help with contributing to Ansible collections general module

2021-04-07 Thread Sam Doran
Saranya,

Contributing to collections is similar to Ansible Core. The documentation for 
contributing to collections 
<https://docs.ansible.com/ansible/latest/community/contributing_maintained_collections.html>
 is the best place to start. That goes over testing requirements among other 
things.

If you run into issues and need more real time support, you can reach out in 
#ansible-community on chat.freenode.net.

---

Respectfully,

Sam Doran
Ansible Core

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/85E8B714-AFAB-4FBD-A58E-D4BBA0D8B4D4%40redhat.com.


Re: [ansible-devel] role argument validation for arbitrary keys

2021-04-05 Thread Sam Doran
> That's why I was more leaning towards a form of catch-all key.

I think the main issue with this, as the code stands today, is that many of the 
functions that perform the validation compare provided keys to those keys in 
the spec to decide whether or not further work is needed (setting defaults, 
handling aliases, etc.). All that logic would have to be reworked in order to 
allow arbitrary keys (again, this is possible but the level of effort required 
does not seem to justify the change).

> While not terrible, in my view this misrepresents the data.

I agree. It's the only disadvantage to this approach, especially when you need 
a dictionary and all the behaviors inherent to that type. Most of the time in 
Ansible, a list of dicts is sufficient to accomplish the same goal. But I do 
understand the drawbacks.

---

Respectfully,

Sam Doran
Ansible Core

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/4B33D2DD-ACDF-478D-97EC-70AB1A5E5CAF%40redhat.com.


Re: [ansible-devel] role argument validation for arbitrary keys

2021-03-30 Thread Sam Doran
Patrick,

Thanks for reaching out on the mailing list. We came across that issue during 
our biweekly triage meeting where we don't have time to respond in detail since 
we are just trying to evaluate all the issues in the queue.

The first problem with allowing arbitrary keys in the argument spec is it goes 
against the intention of how argument spec validation in Ansible is designed to 
work. Namely, for each key specified, run the value through 
check_type_[something] to validate and coerce the data to the correct type.

Argument spec validation in Ansible is not meant to be a generic schema 
validation mechanism, but rather a somewhat strict input validation system that 
provides a stable set of defined variables a module can depend on as input. 
Argument spec validation takes care of defining all parameters in the spec to 
at least a value of None or provides a default value if specified.

As you pointed out, allowing arbitrary keys means we also need to have a system 
for handling those. If we allow arbitrary keys and assume the default type 
(raw) they would pass validation, but may contain completely incorrect data 
(check_type_raw just returns the passed in value).

To do this properly, we would have add features to the argument spec to allow 
for setting the default intended type, or some other behavior, so the 
appropriate checker can be selected for keys that are not explicitly declared. 
Adding toggles that change behavior is a pattern I try to avoid ("'type': 
'dict' sometimes allow arbitrary keys, but sometimes doesn't, depending on if 
have the 'allow_undefined_keys=True' parameter set and don't forget to also set 
'default_type_for_undefined_params='str'" as a hypothetical example).

This would also allow bogus data in, such as key names with typos. This could 
confuse and frustrate the user when the modules/role passes validation but they 
later see errors for undefined variables or default values being used when they 
thought they had specified a value.

I'm sure there are probably some issues with setting defaults and possibly 
aliases as well. Most of the challenges would be in 
_validate_argument_values(), _validate_argument_types(), or 
_validate_sub_spec(). 

While it is possible to change argument spec validation to allow arbitrary keys 
for dictionaries (anything is possible in software), it goes against the design 
intention of the feature in Ansible and would most likely have a lot of odd 
ripple effects both in the implementation and in bugs it would introduce.

A better way to get close to accomplishing what you want would be to use 
'type': 'list' with 'elements': 'dict', as mentioned in the issue. You would 
have to change the input data from a dict to a list, but it would allow 
validation of the structure of each element in the list and avoid the problem 
of arbitrary keys in a dictionary.

{
'users': {
'type': 'list',
'elements': 'dict',
'options': {
'name': {'type': 'str', 'required': True},
'id': {'type': 'int'},
'home': {'type': 'path', 'required': True},
}
},
}


---

Respectfully,

Sam Doran
Ansible Core

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/FC8490E8-12E9-41E6-83E8-F62D62EBDB91%40redhat.com.


[ansible-devel] Ansible releases delayed due to extreme weather

2021-02-16 Thread Sam Doran
Extreme winter weather has caused power outages across parts of the US. As 
a result, the next round of Ansible relases has been delayed until further 
notice while our team focuses on trying to stay warm and safe. 

---

Sam
Ansible Core

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/a012bac3-c171-42f5-99ee-270e710b4865n%40googlegroups.com.


Re: [ansible-devel] Ansible 2.10 and Project Restructuring

2020-06-29 Thread Sam Doran
Matt,

Hopefully the documentation provided by Felix answered some of your questions. 
I'll try to add a little more clarity.

> Do I need to clone both the collection repo, and the main ansible/ansible 
> repo?

No, but with some short term caveats.

If you are only interested in working on collection content, then there is no 
need to clone the ansible/ansible repo or run the hacking setup script. You 
only need to clone the collection repo and make sure it is in your collection 
path.

The caveat is that Ansible 2.9, the current released version, has basic support 
for collections. This was improved greatly in 2.10, which has not been released.

Start by using the latest version of Ansible 2.9 rather than a source checkout 
of ansible/ansible. If you run into any issues, try using 2.10 which you can 
install via pip.

pip uninstall ansible && pip install ansible --pre

If you want to run the ansible source as well as the collection source, you 
certainly can do that (that's how I work). But it is not required to use a 
source checkout of ansible/ansible in order to develop collections.


> What is the new process for testing changes to the modules that have moved to 
> a collection?
> If I want to run my code locally 
> <https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#exercising-module-code-locally>
>  what do I pass as the -m argument? What folder do I need to be in?

If you have the module in your collection path, you can test the module using 
its fully qualified collection name (FQCN). For example, if you module is 
located at:

~/.ansible/collection/ansible_collections/matt/my_collection/plugins/modules/my_module.py

You can run this module with this command:

ansible all -m matt.my_collection.my_module -a '[args]'

> What about unit tests 
> <https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html#unit-tests>.
>  Is the command the same? What folder do I need to be in?
> How do I run integration tests? The new AWS collection repo does not have the 
> policy file listed in the docs.

Per the docs 
<https://docs.ansible.com/ansible/devel/dev_guide/developing_collections.html#testing-collections>,
 unit and integration tests must be run from the root directory of the 
collection. The command is the same.

Regarding the AWS test questions, I am not sure about the policy file. It would 
be best to ask in #ansible-aws on Freenode IRC


---

Respectfully,

Sam Doran

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/105B07BA-2271-45AE-B190-6427F25B6870%40redhat.com.


[ansible-devel] Re: Unable to see third-party module on devel branch

2020-05-18 Thread Sam Doran
That's not a stupid question at all, especially since things in the 
development branch of ansible/ansible have changed quite a bit recently.

We recently migrated most modules to collections. The Digital Ocean modules 
were moved to the community.general 

 collection. 
Pull requests and new modules for Digital Ocean should be submitted to that 
repository.

You can clone that repository and begin working on it using this command:

git clone https://github.com/ansible-collections/community.general 
~/.ansible/collections/ansible_collections/community/general

---

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/77a1489b-7ad0-4e65-9973-e9aad7b9882e%40googlegroups.com.


Re: [ansible-devel] Become plugin

2020-02-13 Thread Sam Doran
We unfortunately don't have docs specific to developing become plugins. They 
are pretty straightforward compared to other plugin types, though. I would 
recommend looking at the existing become plugins 
<https://github.com/ansible/ansible/tree/devel/lib/ansible/plugins/become> to 
get an idea of how to write you own. You can ask development questions here or 
on Freennode IRC in #ansible-devel.

---

Respectfully,

Sam Doran

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/2B3301DB-DF9D-40AA-A6C5-B89B22F36FEB%40redhat.com.


Re: [ansible-devel] Why not environment variable to store vault secrets ?

2019-11-12 Thread Sam Doran
Gabriel,

> Maybe the developpers fear that some users could do things like :
> export VAULT_PASSWORD="MYPASSWORD"
> ansible-playbook ...
> 
> which is of course a bad idea because the password is written in shell 
> history... 

That's pretty much it: we don't want to encourage folks to store passwords in 
environment variables.

---

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/96342B07-6229-4C48-AE3C-1E1122E84639%40redhat.com.


[ansible-devel] Re: Using variables from custom script

2019-09-09 Thread Sam Doran
Mikel,

You can use the reboot plugin 
 with a 
conditional to control when the system is rebooted.

- name: Reboot the system
  reboot:
  when: my_yum_variable != 'new'


This question is better answered on the Ansible Project mailing list 
 or #ansible on IRC 
.

>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/664c0d7e-2951-4327-96e6-15fba1218889%40googlegroups.com.


Re: [ansible-devel] Developing plugin for Aerohive wireless access points - need another set of eyes

2019-07-23 Thread Sam Doran
Dennis,

Developing network modules and plugins is much more challenging than standard 
modules and plugins due to all the moving parts. But once you get the terminal 
and cliconf plugins ironed out, it becomes much easier to focus on the logic 
involved in specific modules.

I would start with hiveos_facts and hiveos_command modules. From there you 
could create a generic hiveos_config module that looks for lines in the config, 
or you could create modules like hiveos_ssid, hiveos_radio_profile, 
hiveos_user, hiveos_group, hiveos_user_profile, etc. that take parameters and 
ensure the necessary config is set on the device without forcing the user to 
know the specific command syntax.

You can always reach out in #ansible-devel or #ansible-network on IRC for more 
help, or we can continue the discussion here. Whatever is easiest for you.

---

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/76041D75-F0DC-4999-AD16-7663486820B2%40redhat.com.


Re: [ansible-devel] Developing plugin for Aerohive wireless access points - need another set of eyes

2019-07-22 Thread Sam Doran
Dennis,

I think it's great you're working on this. I am a long time Aerohive user and 
these modules would be very handy.

Starting with the IOS modules as a base brings along a lot of extra cruft you 
won't need. Those are the oldest modules and require the most work arounds due 
to variations between versions of IOS. HiveOS is much cleaner (mainly because 
it's a newer OS) and should not need nearly as much code.

I would look at the EdgeOS and VyOS plugins and modules as much simpler and 
cleaner examples to follow.

I pared down the attached plugins 
 and managed 
to get them working. This may be a better starting point for you (though I'm 
sure there is still a lot more refinement that can take place).

Have a look at this article on Developing network_cli Platforms 
.
 It provides a good overview of the pieces needed for new platforms. Also look 
at network connection plugins 

 in the developer docs.


---

Sam

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/53960013-AE4F-4795-B6E2-DD2B15564B09%40redhat.com.


Re: [ansible-devel] Where should issues against new gcp_ modules be filed?

2018-08-27 Thread Sam Doran
Nick,

Please open issues on GitHub[1]. If you want to submit a fix, please open a 
pull request on GitHub[2].

The GCP modules are community maintained, so you can also reach out to the 
maintainers directly. Module author information can be found in the module 
documentation.

[1]: 
https://docs.ansible.com/ansible/latest/community/reporting_bugs_and_features.html
[2]: 
https://docs.ansible.com/ansible/latest/community/how_can_I_help.html#review-and-submit-pull-requests

---

Sam Doran

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Need to execute complex unix commands

2018-04-09 Thread Sam Doran
If you need to execute complex shell command, a script file run by the script 
module is your best bet.

This particular examples look like you're analyzing running processes and 
getting a string back, not making changes to the system. This type of thing is 
better done by a facts plugin. Look at service_facts 

 for an example.

---

Sam

> On Apr 9, 2018, at 02:41, Akash Agarwal  wrote:
> 
> Hi All,
> 
> I need to execute complex shell commands on remote or local hosts. What is 
> the best way to this?
> 
> I tried multiple ways. Either it is not passing Ansible syntax, or shell 
> script syntax
> 
> Example:
> 
> Suppose I want to execute this command
> 
> echo "ps -ef|grep data"|sed 's~[^[:alnum:]/]\+~~g'|sed "s/$/$(date 
> +"%d_%m_%Y_%H_%M_%S")/"
> 
> It gives following output on shell : 
> psefgrepdata09_04_2018_12_08_55
> 
> But somehow I am not able to execute. Urgent help please ?
> 
> Thanks,
> Akash
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to ansible-devel+unsubscr...@googlegroups.com 
> .
> For more options, visit https://groups.google.com/d/optout 
> .

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-devel] Custom module to get list of open linux ports and running services

2018-04-02 Thread Sam Doran
Akash,

There is a service_facts 
<https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/system/service_facts.py>
 module that shipped in Ansible 2.5 that will list services. To get the open 
ports on a system, it would be much easier to write a custom facts module and 
parse the data rather than trying to parse the command output it in the 
playbook. You can use the run_command method to get the output, then parse it 
in Python, and return the results in a dictionary via the exit_json method.

---

Respectfully,

Sam Doran

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.