Ask Your Question
0

Can augeas resource edit a file outside the recognized path ?

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

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

1 Answer

Sort by ยป oldest newest most voted
0

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

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 -0500

Seen: 10 times

Last updated: Jun 08