puppet line

48 views
Skip to first unread message

puppetstan

unread,
Mar 25, 2014, 1:11:07 PM3/25/14
to puppet...@googlegroups.com
Hi,

I have 2 problems with lines functions : the first and the second ;)

My configuration :

I create line functions (present, absent...)

define line ($file, $line, $ensure = 'present') {
    case $ensure {
        default : {
            err("unknown ensure value ${ensure}")
        }
        present : {
            exec {
                "/bin/echo '${line}' >> '${file}'" :
                    unless => "/bin/grep -qFx '${line}' '${file}'",
                    logoutput => true
            }
        }
        absent : {
            exec {
                "/bin/grep -vFx '${line}' '${file}' | tee '${file}' > /dev/null 2>&1" :
                    onlyif => "/bin/grep -qFx '${line}' '${file}'",
                    logoutput => true
            }
        }
...
...
...


Il create a profil class with line function


class profil::redhat {
line {'alias vim':
            file => '/root/.bashrc',
            line => "alias vi=\'vim\'",
            ensure => present
    }
line {'alias color':
            file => '/root/.bashrc',
            line => "alias grep=\'grep --color\'",
            ensure => present
    }
}


First problem : a single quote problem

My result in my '/root/.bashrc' file, i would like

alias grep='grep --color'
alias vi='vim'

but i have

alias grep=grep --color
alias vi=vim

Can you have an idea to protect single quote?


Second problem : my manifect consider that alias grep=grep --color
 is absent in my '/root/.bashrc' file but is present so he create this line all the time


alias grep=grep --color
alias grep=grep --color
alias grep=grep --color
alias grep=grep --color

I think it's the space beetween grep and --color

can you have an idea

thanks a lot in adavace
regards

Spencer Krum

unread,
Mar 25, 2014, 1:16:21 PM3/25/14
to puppet...@googlegroups.com
Hi,

I really think you want to use the file_line type from the puppetlabs-stdlib module.

Thanks,
Spencer


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/3942e61e-4391-4f49-9309-9b3c3dc5c535%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Spencer Krum
(619)-980-7820

puppetstan

unread,
Mar 26, 2014, 6:29:33 AM3/26/14
to puppet...@googlegroups.com
ah yes thanks a lot , it's better!!
Reply all
Reply to author
Forward
0 new messages