0

I have a question, Is it possible in puppet to do things as different user, for instance I want to install git, vim, curl as root and install postgresql as vagrant. Is it possible to do?

class apt_update {
        exec { "aptGetUpdate":
                command => "sudo apt-get update",
                path => ["/bin", "/usr/bin"],
                user => root,
        }
}

class othertools {
        package { "git":
              ensure => latest,
              require => Exec["aptGetUpdate"],

        }

        package { "vim-common":
              ensure => latest,
              require => Exec["aptGetUpdate"],
        }

        package { "curl":
              ensure => present,
              require => Exec["aptGetUpdate"],
        }

        package { "htop":
                ensure => present,
                require => Exec["aptGetUpdate"],
        }
}


node "vagrant-ubuntu-trusty-64" {

        include apt_update
        include redis
        include mongoose
        include othertools

        class { 'postgresql::globals': }
        class { 'postgresql::server':
                ip_mask_allow_all_users    => '0.0.0.0/0',
                ipv4acls                   => ['host    all     postgres        127.0.0.1/32    trust'],
                listen_addresses           => '*',
                postgres_password          => '12345',
        }
        postgresql::server::db { 'springfruit_dev':
                user     => 'chat_app',
                password => postgresql_password('chat_app', '12345')
        }

}

P.S. I know that it is possible to run exec and file as root. Question is what about other stuff?

6
  • 3
    Why do you want to "install postgresql as vagrant"? Aug 6 '14 at 4:56
  • @MichaelHampton actually I need to do something as root, and other as vagrant. The actual problem is that I install ssh keys(git) for vagrant user and need to clone repo, but to install git curl vim postgres I must be run root, so I can't clone because keys installed for vagrant not root. That's why I ask how to do different stuff as different user.
    – Slow Harry
    Aug 6 '14 at 5:00
  • 1
    Puppet is great for configuring a server, but is probably not the best tool for deploying your app. Use something designed for that purpose, such as Capistrano. Aug 6 '14 at 5:05
  • But Chef can do it!
    – ewwhite
    Aug 6 '14 at 5:10
  • 1
    @SlowHarry please note that root can use whatever SSH keys she damn well pleases. Aug 6 '14 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.