Questions tagged [ansible-module]
75 questions
6
votes
1 answer
How do I add a repository with Ansible on CentOS 8?
In CentOS 7, Ansible has the yum-repository module that can be used for adding repositories.
In CentOS 8 there exists the dnf module for package management, but there doesn't seem to be a dnf-repository module to add repositories.
How do you achieve…

fignet
- 305
- 2
- 7
4
votes
1 answer
Can I specify that an argument can't be used with a specific choice in Ansible module spec?
I'm looking for a way of specifying that a module argument can't be used if another argument has a certain value.
You can specify required_if to require an argument if another argument has a specific value but I need the opposite.
Something that's…

Wes Toleman
- 311
- 5
- 12
3
votes
1 answer
Ansible: How to execute set_fact module from within ansible action plugin python code
I am writing a custom Action Plugin for Ansible which I use in my playbook and I am trying to set a variable that will be used in the next task, in the playbook, by a (custom) module.
Effectively, the playbook equivalent of what I am trying to mimic…

hs14428
- 109
- 5
3
votes
1 answer
Kubernetes Module appears to be missing but looks like it is installed
I get this error:
ERROR! couldn't resolve module/action 'kubernetes.core.k8s'. This often indicates a misspelling, missing collection, or incorrect module path.
However, I thought I installed it and looks like it is installed:
[me@server ansible]$…

Benjamin W Larson
- 49
- 2
- 9
2
votes
1 answer
After running a SQL query using the ansible mysql_query module, how do I extract the data returned?
I have a playbook that is retrieving data from a test database, but I am unable to figure out how to extract the rows returned from the database.
The whole purpose of the exercise is to pull the value from the KVP and add it to a report, so eventual…

biker_steve
- 21
- 2
2
votes
1 answer
Using a shared file in multiple ansible modules
I am currently developing a number of Ansible modules using Python.
My directory structure looks like this:
/
playbook.yml
library/
module1.py
module2.py
Using this, I can run the playbook (which uses my modules) via
ansible-playbook…

mat
- 1,645
- 15
- 36
2
votes
1 answer
How can I print a warning message from within a custom module in Ansible?
I've created a custom module based on the description in the Ansible docs.
The docs explain to fail the module with module.fail_json(). Instead of failing and printing an error message, I want to output just a warning message without failing. How…

Wolfson
- 1,187
- 17
- 22
2
votes
1 answer
Pass Ansible variables into custom Ansible module
I have a custom module that resides in the library/ directory of my Ansible role. I can call the module from within my playbook, and the code executes correctly, but only if the values it expects are hardcoded in the module code itself. How can I…

GreNIX
- 47
- 1
- 6
2
votes
2 answers
Ansible - Filter Dictionary Values
I have gathered the list of all users using getent_module:
- name: Get user info
getent:
database: passed
This returns this variable as getent_passwd, a dictionary like this:
{
"uuidd": [
"x",
"107",
"112",
…

Shaghayegh Tavakoli
- 520
- 3
- 21
2
votes
2 answers
Ansible on a linux like OS answer a question I need to answer with yes
I have a DataDomain System which I can enter via ssh. I need to automate a procedure on the DataDomain which does aks a question after a command:
storage add tier active dev3
Object-store is not enabled. Filesystem will use block storage for user…

Juergen Schubert
- 121
- 4
- 12
2
votes
1 answer
using lineinfile to insert line but not working as expected
I am using lineinfile to insert line in syslog file. Here is my syslog:
/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
missingok
sharedscripts
postrotate
/bin/kill -HUP `cat…

saranjeet singh
- 868
- 6
- 17
2
votes
1 answer
ansible module stop and start service ssh
I am trying to clear a hands on in HackerRank, where the task is to stop and start the service named ssh using service module. I have used the below code.
- name: "Stop ssh"
service:
name: ssh
state: stopped
- name: "start ssh"
service:
…

Mahesh
- 48
- 5
2
votes
1 answer
Ansible file processing / blockinfile module in Windows
I want to udpate block of multiline text in a file in Windows via ansible. Have used blockinfile
but it works only on Linux machines. Are there any alternative for this module ? Or any other way to do this? There is win_lineinfile but I have around…

user2700022
- 489
- 3
- 19
2
votes
4 answers
How to check file exist in path with extension in Ansible?
I just want to know about how to check the file exists or not any directory via ansible code. I have tried with stat module with path "*.test" already but it did not working.
Below is my trying:
- name: Check license file exist or not
stat:
…

Kimly Vith
- 53
- 1
- 6
1
vote
0 answers
ansible.builtin.unarchive - permission denied
I'm downloading a file to the ansible controller, distribute it to several (3) hosts und unarchive it to a certain directory. I have sudo access to all machines.
The code is the following:
- name: Install ZULU Java package
hosts: jenkins
become:…

adminkc
- 11
- 2