On Wednesday, May 16, 2018 at 7:45:10 AM UTC-5, Jochen Haeberle wrote:
>
> Hi again,
>
> as outlined in my last post, I am trying to setup seafile using Puppet
> 5.5.1 on Debian 9.
>
> I am struggling with a script based installation. As a work around, I
> tried to separate the steps. I want to prepare an answer file for the setup
> script, run that and adjust the config on the second puppet run.
>
Splitting the setup between running the script and afterward tweaking the
config seems entirely reasonable, but I don't see why that can't all be
done in the same catalog run.
>
> I am having two problems:
>
> When the script is run, there exists a symlink in the filesystem.
> Following a recipt from not so long ago, I want to use this:
>
> exec {"check_installed":
> command => '/bin/true',
> onlyif => "/usr/bin/test -e /opt/seafile/${instanz}/seafile-server-latest",
> }
>
>
>
So you mean you want to use a resource *similar to* that? Because I don't
see what you could expect that exact resource to accomplish for you. It
will always succeed, so it can be run at any point in the catalog run, and
its success tells you nothing. It doesn't even have any useful
autorequires.
> 1) I want to move the data folder created by the installer to a networked
> folder and create a symlink afterwards.
>
Have you considered creating the link one level up? That is, /opt/seafile
-> /mnt/seafile? If that suffices for you, then it could make the whole
process easier.
> The exec moving the folder is waiting for the existence of the folder
>
I don't know what you mean by that.
> , but the file resource doing the link is always executing. It seems like
> Puppet behaviour changed massively from version 3
>
Not in any way that seems relevant to your problem. I think you've somehow
formed an incorrect expectation.
> I cannot find a working solution for this except writing a fact, which
> seems not manageable, as a fact may not be parameterized.
>
Facts are not parameterized, but you could certainly write a fact that
reported, say, *all* of the ${instanz} values such that
/opt/seafile/${instanz}/seafile-server-latest exists. It seems that would
give you the information you would need, though I don't think this approach
is necessary in the first place.
> Is there a way to control execution of a file resource?
>
You can control the *order* in which a File or any resource is applied
relative to other resources via the usual relationship operators and / or
metaparameters. You can control *whether* a resource is applied via
conditional statements in your manifest (that evaluate conditions known at
catalog-building time to the catalog builder).
> This runs all the time:
>
> file { "/opt/seafile/${instanz}/seafile-data":
> ensure => 'link',
> target => "/mnt/seafile/${instanz}/seafile-data",
> require => Exec['check_installed'],
> }
>
>
>
Of course it does. Why shouldn't it?
> after that, the seafile installer will not run through, as the data-folder
> is already there.
>
So you ensure that if the script needs to run at all, then it runs before
that file is applied, and also before the resource that moves the
installation per your requirement.
>
> 2) I need to change the ini-based config crated during the setup. Problem
> is similar, whatever I do, this always runs and gives me an error:
>
> ini_setting { "URL ${instanz}":
> ensure => present,
> path => "/opt/seafile/${instanz}/conf/ccnet.conf",
> section => 'General',
> setting => 'SERVICE_URL',
> value => "https://${url}",
> require => Exec['check_installed'],
> }
>
> This is not that problematic, it gives an error, but puppet continues on.
> But I guess, I could run 1) as exec to solve it, but not 2)
>
Again, you seem to have an incorrect expectation about what your
Exec['check_installed'] will do, or what expressing a requirement on it
will achieve (i.e. nothing).
Overall,
*First choice*: move the symlink up one level, as already discussed, so
that you can install directly to your network filesystem. Set up
relationships among your resources like so: File[/opt/seafile] ->
Exec[installer] -> Ini_setting["URL ${instanz}"].
*Second choice*: Set up relationships among your relationships like so:
Exec[installer]
-> Exec['move data'] -> File["/opt/seafile/${instanz}"] -> Ini_setting["URL
${instanz}"].
Either way, use the 'onlyif', 'unless', and / or 'creates' attributes of
your Execs appropriately to indicate whether their main 'command' needs to
run. Note well -- and perhaps this is a key point confusing you -- that
when those attributes indicate that an Exec's command does not need to run,
the Exec then *succeeds*. You can conceptualize that as the Exec already
being in sync.
John
--
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/c85a5dd9-1cbe-4092-90e2-9537a465de12%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.