LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise
User Name
Password
Linux - Enterprise This forum is for all items relating to using Linux in the Enterprise.

Notices


Reply
  Search this Thread
Old 05-21-2020, 08:32 AM   #1
chrisperrault
LQ Newbie
 
Registered: Nov 2013
Location: Massachusetts
Distribution: Centos,Mageia, Redhat, Fedora
Posts: 7

Rep: Reputation: Disabled
Question on validate parameter for Ansible copy module


Hi everyone,

I'm somewhat new to Ansible and I have some questions regarding the validate parameter to the copy module.

I have a playbook that takes a sudoers file from a central location and copies it to the host(s). I just noticed the validate parameter to copy (there apparently are several modules with this parameter) and realized this is something I probably want to utilize in the case of putting a new sudoers file in place.

My problem is, while I have the playbook 'working' I'm still thinking I didn't do this correctly:

---
- name: Configure sudoers
hosts: all
gather_facts: yes
tasks:

- name: Copy sudoers file
copy:
src: /var/files/lxcfg/cfgfiles/rhel/7/soe/sudoers
dest: /etc/sudoers
mode: 0440
owner: root
group: root
backup: yes
validate: visudo -csf %s


The first question is, while I know I have to provide the %s to validate(putting in an absolute path didn't work for me), what value is being plugged into %s? Is it taking it from my dest value?

At first I thought that validate first copies the file to a temporary file, does the test (visudo in this case), and then does the final copy to /etc/sudoers. Now I'm thinking it just copies it to /etc/sudoers and does the test 'in place' which is what I don't want to be doing in this case.

If validate does use the dest path as the value for %s, I can very easily just change the dest to a temp file and then ad a second copy to take the temp file and put it in the right place. I'm just really unclear on how the validate parameter works and the limited documentation on it that I've seen so far only says that %s is required. It doesn't tell me what is plugged into that value.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ansible Guide: Manage Files using Ansible LXer Syndicated Linux News 0 04-26-2019 10:32 AM
LXer: Ansible Guide: Create Ansible Playbook for LEMP Stack LXer Syndicated Linux News 0 04-13-2019 05:03 AM
LXer: Ansible Tutorial: Introduction to simple Ansible commands LXer Syndicated Linux News 0 05-21-2018 10:28 AM
LXer: Ansible Tutorial: Intorduction to simple Ansible commands LXer Syndicated Linux News 0 01-14-2018 05:37 PM

LinuxQuestions.org > Forums > Enterprise Linux Forums > Linux - Enterprise

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration