Search code examples
phppuppetpuphpethiera

PuPHPet Vagrant create symlink


I used PuPHPet to create a Puppet config for a PHP project (https://puphpet.com/#create). I've read that it uses Hiera, but I'm really not too familiar with the Puppet/Hiera syntax.

I want to create a symlink from a synced folder to my web root. I found out how to do it with Puppet, but I don't know how that fits in with my config files:

file { '/tmp/link-to-motd':
   ensure => 'link',
   target => '/etc/motd',
}

http://puppetcookbook.com/posts/creating-a-symlink.html

Is there some trick to do this in Hiera? It seems like Hiera uses a YAML file to configure everything. Sorry if I'm completely missing something obvious here.

For example I have this in my config.yml

vagrantfile-local:
    vm:
    ...
        synced_folder:
            0H4IdhbRXpVN:
                source: .
                target: /var/project
                sync_type: default
                rsync:
                    args:
                        - '--verbose'
                        - '--archive'
                        - '-z'
                    exclude:
                        - .vagrant/
                    auto: 'false'
...
apache:
    install: '1'
    settings:
        user: www-data
        group: www-data
        default_vhost: true
        manage_user: false
        manage_group: false
        sendfile: 0
    modules:
        - rewrite
    vhosts:
        RXTueD2ha3Pa:
            servername: mysite.dev
            docroot: /var/www/mysite
            port: '443'
            override:
                - All
            options:
                - Indexes
                - FollowSymLinks
                - MultiViews
            engine: php
            custom_fragment: ''
            ssl: '1'
            ssl_cert: ''
            ssl_key: ''
            ssl_chain: ''
            ssl_certs_dir: ''

And I want /var/www/mysite to be a symlink to /var/project/web.

I guess I could always create an exec-once shell script to do this, but hoping for a way to put this in the config.


Solution

  • The easiest way for you to do this is to create a super simple bash script and throw it into the exec-once folder, which will run one time on the initial $ vagrant up.