Questions tagged [ansible-module]
75 questions
1
vote
1 answer
How load a yaml file inside an ansible custom module
I have an ansible custom module, that have a configuration file in YAML format.
Now the question is how should I load that YAML file inside the module?
NOTE as I understand I can't simply use something like PyYAML since ansible will run my module on…

ansible_user
- 11
- 1
1
vote
1 answer
Not able to run custom module
I created a custom module called pingtest which pings all the server using the ping command. I have created a shell script for that and later placed it inside the library directory of the playbook directory. When I wrote a playbook to use that…

kishan agarwal
- 43
- 6
1
vote
1 answer
How to create an Ansible module or plugin to dynamically generate files to push?
I am using Ansible to deploy sudoers file in all the server the sudoers rights are stored in a central repository and dynamically generated via Python libraries installed locally on the Control Node.
I've tried to create a Python script on the…

zn553
- 87
- 7
1
vote
2 answers
Ansible Custom Module in Python - How to resolve relative role file paths?
I'm writing a new Ansible Custom Module in Python.
I want to be able to resolve paths in my code (in order to read their content) just as file and copy modules do when receiving a relative path in src argument (the path is relative to…

Eyal Roth
- 3,895
- 6
- 34
- 45
0
votes
0 answers
How to change ansible user module uid behavior after manual additions
Lets assume the following commands which will add three users. The first one will be created automatically with proper uid assignment. Afterwards I define a second user which needs to have a specific uid due to reasons. At last I add a third user…

Sefer
- 1
- 1
0
votes
2 answers
Is it possible to use an Ansible Core Module within a Custom Module?
There is also this related question "Access predefined ansible modules in custom module" but unfortunately without an helpful answer.
In general, I would like to create a Custom Module which uses some Core Modules.
If I e.g. want to use the Core…

Stefan
- 1,697
- 15
- 31
0
votes
0 answers
Ansible Custom Module: How to implement conditional parameter?
I want to create a Custom Module call API which will take
action: get or search
resource: car/truck/plane/ship
optional parameters - dynamic parameter based on action and resource
For example if action is get and resource is car, then I want to…

tempuser
- 1,517
- 3
- 11
- 15
0
votes
1 answer
How do I pass configuration variable to plugins in a collection?
I have an Ansible collection for managing TrueNAS boxes. The core is a utility class that talks to the middleware daemon to check the configuration and make changes. There's a command-line utility to talk to the daemon, but there's also a Python…

arensb
- 159
- 8
0
votes
0 answers
Ansible-Lint warning for custom module argument exception
I have a custom module to manage Keycloak realms. That module takes a long list of arguments including a sub-dictionary for smtp_server:
def keycloak_argument_spec():
return dict(
auth_keycloak_url=dict(type='str', aliases=['url'],…

TRW
- 876
- 7
- 23
0
votes
1 answer
How do I get the latest Amazon LInux 2 ami using Ansible?
I'm using Ansible to provision AWS EC2 instances with the Amazon.Aws collection. On the cli, if I want to get the latest Amazon Linux 2 AMI I may run something like this:
$ aws ec2 describe-images \
--region us-east-1 \
--owners amazon…

Chris King-Parra
- 1
- 2
0
votes
0 answers
How do i use the following apt options (sourcelist sourceparts List-Cleanup) in ansible module?
I want to run the following apt command via the ansible module.
apt-get update -o Dir::Etc::sourcelist="sources.list.d/mypackages.list" -o Dir::Etc::sourceparts="-" -o APT::Get::List-Cleanup="0"
I don't want to use the shell module for this purpose…

Shubham Saroj
- 290
- 2
- 12
0
votes
1 answer
How to access tasks parameters from an Ansible task in the Python module code?
Is it possible to access Ansible tasks parameters from the Python module code?
Specifically, I would like to check if there is a register on the task in order to return a more complete info set.

mooky
- 87
- 5
0
votes
0 answers
I want to write a set_group_fact Ansible module - Is it possible to access or change facts across multiple hosts in an action plugin?
I have worked with Ansible for a while now and am comfortable with it, but am only now beginning to explore writing custom modules and plugins. I have come up with some simple concepts for modules and plugins that I'd like to write as an exercise to…

oO.o
- 87
- 1
- 1
- 6
0
votes
0 answers
Ansible Expect module handling duplicate keys/questions in flow
Trying to get the expect module to configure a Jira set-up - the module seems to work until the question is repeated - essentially the last two entires.
See the script questions below (With redacted data)
----------------------
JIRA Configurator…

bfowler
- 49
- 1
- 9
0
votes
2 answers
Replace all strings with loop - ANSIBLE
I'm trying to change CISCOASA word here using the output I got. I've tried using lineinfile module in ansible but the replacement is not in order.
ORIG JSON FILE:
{ "servers": [
{
"ingress": "CISCOASA",
"protocol": "tcp",
"source_ip":…

RRRR
- 1
- 1