Ask Your Question
0

Can augeas resource edit a file outside the recognized path ?

asked 2017-06-08 02:12:12 -0600

Jonathan Schaeffer gravatar image

Hi,

I need to add lines in the .ssh/config file of a specific user. I choose to use augeas to do so, because, in reality, it is a collection of various exported resources. So basicaly :

   augeas{"ssh_config_deployer_local":
    context => '/files/deployer/.ssh/config',
    changes => [
      "set host ${hostname}",
      "set user deploy"
    ],
  }

Turns out this won't work, because augeas does not manage this path (/deployer/.ssh/config). So I tried it another way around :

  augeas{"ssh_config_deployer_local":
    context => '/files',
    incl    => '/deployer/.ssh/config',
    lens    => 'Ssh.lns',
    changes => [
      "set host ${hostname}",
      "set user deploy"
    ],
  }

withou success.

How can I tell the augeas resource to edit this file with the Ssh lens ?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2017-11-17 09:12:48 -0600

ManzTheReader gravatar image

If you remove the 'files' attribute it should work.
However, looks like there is a syntax error still.
Imho, it should look like this:

class tests::augeasssh {
$hostname = 'somehost'
augeas{"ssh
configdeployerlocal":
# context => '/files',
incl => '/tmp/.ssh/config',
lens => 'Ssh.lns',
changes => [
"set Host ${hostname}",
"set \"Host[.=\"${hostname}\"]/User[.=\"deploy\"]\" deploy"
],
}
}

edit flag offensive delete link more
0

answered 2017-06-08 03:08:29 -0600

Jonathan Schaeffer gravatar image

This is not a real solution to the general problem of using augeas for specific files. But for my specific problem, I switched to the Concat::fragment module.

    @@concat::fragment{"ssh_config_deployer_${::fqdn}":
    target  => '/deployer/.ssh/config',
    content => "\nHost ${::hostname}\n  User deploy\n",
    tag     => 'deployer'
  }

and on the collector side :

  concat{'/deployer/.ssh/config':
    ensure => present
  }
  Concat::Fragment <<| tag == 'deployer' |>>
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: 2017-06-08 02:12:12 -0600

Seen: 155 times

Last updated: Nov 17