Ask Your Question
0

How to create folder name with custom facts using puppet in Windows ?

asked 2016-04-05 09:27:47 -0500

yoga gravatar image

I wrote a custom fact to create current date and time in windows.That facts return the current date and time when i notifying it.

Eg:

           notify{"test time":
           message=>"$::windows_time",
             }

output of above code is '05-04-2016-194645'

But When i have tried to create a folder with custom facts , I can't create a folder with timestamp. My Code is below.

        exec{"current date time folder":
        cwd=>"${prodequ_backup_loc}",
        command=>'C:\Windows\System32\cmd.exe /c "md $::windows_time"',
             }

That above code created a folder name with "${windows_time}".

my facts for creating date and time-stamp is below:

              require 'facter'
              #
              ##Default for non-Linux nodes
              Facter.add(:windows_time) do
              setcode do
               Facter::Util::Resolution.exec('C:\\Windows\\System32\\cmd.exe /c "C:\\time1.bat"')
              end
              end
              #For Linux Nodes
               Facter.add(:windows_time) do
               confine :kernel  => :linux
               setcode do
               nil
               end
               end

Any help is much appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-04-07 03:43:42 -0500

yoga gravatar image

I changed my code. now am using file resource to create directory instead of exec resource . my code is below:

          class currentgen::backup::folder_backup
              ($prodequ_backup_loc        = $prodequ_backup_loc,
               $time=$::windows_time,
                )
          inherits currentgen{
                 file {"${prodequ_backup_loc}\\${time}":
                       ensure => directory,
                      }
                 file{"${prodequ_backup_loc}\\${time}/server":,
                      ensure => directory,
                      require=>File["${prodequ_backup_loc}\\${time}"]
                     }
       }

above code creates folder which name created by custom facts.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-05 09:27:47 -0500

Seen: 188 times

Last updated: Apr 07 '16