1

When trying to push a sudoers file to other machines, the rexcm task/command gets stuck.

The Problem is (so it seems to me), that the sudoers file is owned by the rex-user when writing and "other" permission is set, what leads to 'sudo' failing (what leads to breaking "sudo TRUE" in the Rexfile):

mySrv:/etc# ls -l sudoers.d/                                                                                                                                                                          
-rw-rw-r--   1 rexuser rexuser   72 Jul 25 07:49 sudoersFile

I tried to distribute the file from source and from template.

file "/etc/sudoers.d/sudoersFile",                                   
        #source => "files/sudoers.d/sudoersFile",                    
        owner=>"root", group=>"root", mode => "600",                    
        content => template("templates/sudoers.d/sudoersFile.tpl"),  
        on_change => sub{                                               
                say "file sudoersFile transfered";                   
        };                                                              

}; 

Question: What is the (or: is there a) correct way to distribute sudoers files with rex configuration management?



Update/Workaround:
(thx to 'xq' from #rex@freenode)

  • copy the file to a temporary location on the remotesystem (same code like above, but different path)
  • move/copy the files to "/etc" (rex-command for "mv" is "rename", put at the end of the same task definition)

    rename("$tmpDir/sudoers.d/sudoersFile", "/etc/sudoers.d/sudoersFile");
    

    ... the downside: you have to manually provide an "on_change"-event

MacMartin
  • 338
  • 1
  • 4
  • 17

1 Answers1

0

just answering the question with the workaround, mentioned in the question, since there was no new enlightenment in a year:

(thx to 'xq' from #rex@freenode)

  • copy the file to a temporary location on the remotesystem (same code like above, but different path)
  • move/copy the files to "/etc" (rex/perl-command for "mv" is "rename", put at the end of the same task definition)

    rename("$tmpDir/sudoers.d/sudoersFile", "/etc/sudoers.d/sudoersFile");
    

    ... the downside: you have to manually provide an "on_change"-event

MacMartin
  • 338
  • 1
  • 4
  • 17