FAQ
Hi all,

I would like to provide installation and rollback for any module. Here are
was I've tried but not work,

At modules/katie/manifests/init.pp

class katie::add {
tag 'add'
user {'katie':
ensure => present,
}
}
class katie::remove {
tag 'remove'
user {'katie':
ensure => absent,
}
}

class katie {
  include katie::remove, katie::remove
}

test command,

[root@centos ~]# puppet agent --test --tags add
Info: Retrieving plugin
Info: Loading facts in /var/lib/puppet/lib/facter/pip_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/python_version.rb
Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
Duplicate declaration: User[katie] is already declared in file
/etc/puppet/modules/katie/manifests/init.pp:5; cannot redeclare at
/etc/puppet/modules/katie/manifests/init.pp:12 on node centos.local
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
[root@centos ~]#

If this is not the way to go, is there any alternative to get the
install/rollback?

Thanks you,

--
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 puppet-users+unsubscribe@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • JuanBrein at Sep 16, 2013 at 12:47 pm
    Hi Neanudorn

    Is very difficult... you could try but if you really want to do it properly
    is going to take you a lot of time for all the modules. The main problem I
    foresee is that adding things is easy, but removing them is hard as you
    need to identify each of the objects that were added. Ie when you install a
    package a lot of files and configurations are added, but when you remove it
    some configuration files are left in place. Additionally if your
    environment is virtualized then then why not to rebuild the instance with
    the new setup? That is way easier than introduce so much complexity in your
    manifests.

    Said that if you still want to go with that approach, I think the best way
    would be to use parametrized classes:

    Ie:

    class my_app (
       ensure = present
    ) {

       package {'my_package':
         ensure => $ensure,
       }

    }

    And then in the node declaration:

    node /my_node/ {

       class{'my_app':
         ensure => present
       }

    }

    You can then change the ensure parameter to remove that app...

    Hope it makes sense.

    Cheers

    Juan



    On Monday, September 16, 2013 10:31:10 AM UTC+1, Chatchai Neanudorn wrote:

    Hi all,

    I would like to provide installation and rollback for any module. Here are
    was I've tried but not work,

    At modules/katie/manifests/init.pp

    class katie::add {
    tag 'add'
    user {'katie':
    ensure => present,
    }
    }
    class katie::remove {
    tag 'remove'
    user {'katie':
    ensure => absent,
    }
    }

    class katie {
    include katie::remove, katie::remove
    }

    test command,

    [root@centos ~]# puppet agent --test --tags add
    Info: Retrieving plugin
    Info: Loading facts in /var/lib/puppet/lib/facter/pip_version.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/python_version.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
    Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
    Duplicate declaration: User[katie] is already declared in file
    /etc/puppet/modules/katie/manifests/init.pp:5; cannot redeclare at
    /etc/puppet/modules/katie/manifests/init.pp:12 on node centos.local
    Warning: Not using cache on failed catalog
    Error: Could not retrieve catalog; skipping run
    [root@centos ~]#

    If this is not the way to go, is there any alternative to get the
    install/rollback?

    Thanks you,
    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
  • David Schmitt at Sep 18, 2013 at 9:37 am
    Hi,

    Alessandro's modules at http://github.com/example42 do install/rollback
    all the time.

    You might want to look at them how they do it.


    Regards, David
    On 2013-09-16 11:31, Chatchai Neanudorn wrote:
    Hi all,

    I would like to provide installation and rollback for any module. Here
    are was I've tried but not work,

    At modules/katie/manifests/init.pp

    class katie::add {
    tag 'add'
    user {'katie':
    ensure => present,
    }
    }
    class katie::remove {
    tag 'remove'
    user {'katie':
    ensure => absent,
    }
    }

    class katie {
    include katie::remove, katie::remove
    }

    test command,

    [root@centos ~]# puppet agent --test --tags add
    Info: Retrieving plugin
    Info: Loading facts in /var/lib/puppet/lib/facter/pip_version.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/python_version.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/root_home.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/puppet_vardir.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/facter_dot_d.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/concat_basedir.rb
    Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
    Error: Could not retrieve catalog from remote server: Error 400 on
    SERVER: Duplicate declaration: User[katie] is already declared in file
    /etc/puppet/modules/katie/manifests/init.pp:5; cannot redeclare at
    /etc/puppet/modules/katie/manifests/init.pp:12 on node centos.local
    Warning: Not using cache on failed catalog
    Error: Could not retrieve catalog; skipping run
    [root@centos ~]#

    If this is not the way to go, is there any alternative to get the
    install/rollback?

    Thanks you,

    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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 puppet-users+unsubscribe@googlegroups.com.
    To post to this group, send email to puppet-users@googlegroups.com.
    Visit this group at http://groups.google.com/group/puppet-users.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppuppet-users @
categoriespuppet
postedSep 16, '13 at 9:35a
activeSep 18, '13 at 9:37a
posts3
users3
websitepuppetlabs.com

People

Translate

site design / logo © 2022 Grokbase