Ask Your Question
0

How to use file_line with "after" and "multiple=true"?

asked 2017-01-20 12:40:58 -0500

jack9 gravatar image

i am trying to add multiple lines, in my case exclude=nodejs after each occurance of gpgcheck=1, tried multiple variations but most of the time it simple adds nothing.

puppet code:

  file_line { '/etc/yum.repos.d/webtatic.repo':
    ensure            => present,
    multiple          => true,
    after             => 'gpgcheck\=1',
    path              => '/etc/yum.repos.d/webtatic.repo',
    line              => 'exclude=nodejs',
    #match             => 'exclude\=nodejs',
  }

file source:

[webtatic]
name=Webtatic Repository EL7 - $basearch
#baseurl=https://repo.webtatic.com/yum/el7/$basearch/
mirrorlist=https://mirror.webtatic.com/yum/el7/$basearch/mirrorlist
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7

[webtatic-debuginfo]
name=Webtatic Repository EL7 - $basearch - Debug
#baseurl=https://repo.webtatic.com/yum/el7/$basearch/debug/
mirrorlist=https://mirror.webtatic.com/yum/el7/$basearch/debug/mirrorlist
failovermethod=priority
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7

file target:

[webtatic]
name=Webtatic Repository EL7 - $basearch
#baseurl=https://repo.webtatic.com/yum/el7/$basearch/
mirrorlist=https://mirror.webtatic.com/yum/el7/$basearch/mirrorlist
failovermethod=priority
enabled=1
gpgcheck=1
exclude=nodejs
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7

[webtatic-debuginfo]
name=Webtatic Repository EL7 - $basearch - Debug
#baseurl=https://repo.webtatic.com/yum/el7/$basearch/debug/
mirrorlist=https://mirror.webtatic.com/yum/el7/$basearch/debug/mirrorlist
failovermethod=priority
enabled=0
gpgcheck=1
exclude=nodejs
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-webtatic-el7
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-02-09 12:47:58 -0500

puser gravatar image

I just tested your example successfully. I wonder if you do not need to escape the '=' sign:

/tmp/fileline

hi
eric
this
is
a
variable=true
named
variable=true
variable

manifests/init.pp

file_line { 'add-line-tmp-fileline':
    ensure   => 'present',
    after    => 'variable=true',
    multiple => true,
    path     => '/tmp/fileline',
    line     => 'addedline',
  }

result:

/tmp/fileline

hi
eric
this
is
a
variable=true
addedline
named
variable=true
addedline
variable
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

2 followers

Stats

Asked: 2017-01-20 12:40:58 -0500

Seen: 655 times

Last updated: Feb 09