puppetlabs / puppetlabs-node_manager

Create and manage PE node groups as resources.
Apache License 2.0
10 stars 21 forks source link

puppet node_manager pin does not pin or error #44

Closed tkishel closed 5 years ago

tkishel commented 5 years ago

puppet node_manager pin does not pin or error, given ...

Define a group:

[root@pe-201817-master ~]# cat pin.pp 
node_group { 'Pin Test':
  ensure => present,
  parent => 'PE Infrastructure',
}

Create the group:

[root@pe-201817-master ~]# puppet apply pin.pp 
Notice: Compiled catalog for pe-201817-master.puppetdebug.vlan in environment production in 0.05 seconds
Notice: New node_group 'Pin Test' with ID 'ed116200-488e-45ac-99ff-4608c4f48816'
Notice: /Stage[main]/Main/Node_group[Pin Test]/ensure: created
Notice: Applied catalog in 2.39 seconds

Inspect the group (Confirmed in the Console):

[root@pe-201817-master ~]# puppet resource node_group 'Pin Test'
node_group { 'Pin Test':
  ensure               => 'present',
  environment          => 'production',
  id                   => 'ed116200-488e-45ac-99ff-4608c4f48816',
  override_environment => 'false',
  parent               => 'PE Infrastructure',
  rule                 => [''],
}

Pin an existing node:

[root@pe-201817-master ~]# puppet node_manager pin --node_group 'Pin Test' pe-201817-agent.puppetdebug.vlan

Inspect the group (Confirmed in the Console):

[root@pe-201817-master ~]# puppet resource node_group 'Pin Test'
node_group { 'Pin Test':
  ensure               => 'present',
  environment          => 'production',
  id                   => 'ed116200-488e-45ac-99ff-4608c4f48816',
  override_environment => 'false',
  parent               => 'PE Infrastructure',
  rule                 => [''],
}
tkishel commented 5 years ago

Also, why is there no unpin from a specific group?

puppet node_manager unpin --node_group GROUP nodename

:)

WhatsARanjit commented 5 years ago

@tkishel If it's not pinning, that's a bug I should look into.

As for unpinning, when I created the module, this didn't exist: https://puppet.com/docs/pe/2017.1/nc_groups.html#post-v1groupsidunpin

But now it does, so I'll work on adding it.

tkishel commented 5 years ago

Thanks!!!

WhatsARanjit commented 5 years ago

Ok, was able to pin a node successfully. One thing, using the face, which is a little more basic, you have to supply the group ID, not the group name. I did this so each ad-hoc command line action wouldn't run the instances() method and query all groups first. That said, there was still a bug in there anyway. Here's the code so far.

https://github.com/WhatsARanjit/puppet-node_manager/tree/issue44

# puppet resource node_group 'Pin Test' ensure=present
Notice: New node_group 'Pin Test' with ID 'c3094616-479b-4eef-980f-92c1805b2070'
Notice: /Node_group[Pin Test]/ensure: created
node_group { 'Pin Test':
  ensure => 'present',
}
# puppet resource node_group 'Pin Test'
node_group { 'Pin Test':
  ensure               => 'present',
  environment          => 'production',
  id                   => 'c3094616-479b-4eef-980f-92c1805b2070',
  override_environment => 'false',
  parent               => 'All Nodes',
  rule                 => [''],
}
# puppet node_manager pin --node_group 'c3094616-479b-4eef-980f-92c1805b2070' 'test.node'
# puppet resource node_group 'Pin Test'
node_group { 'Pin Test':
  ensure               => 'present',
  environment          => 'production',
  id                   => 'c3094616-479b-4eef-980f-92c1805b2070',
  override_environment => 'false',
  parent               => 'All Nodes',
  rule                 => ['or', ['=', 'name', 'test.node']],
}
WhatsARanjit commented 5 years ago

Alright, added a --all option to the unpin action.

# puppet node_manager unpin --help

USAGE: puppet node_manager unpin [--all] [--node_group GROUP] nodename

Unpin a node from a group

OPTIONS:
  --render-as FORMAT             - The rendering format to use.
  --verbose                      - Whether to log verbosely.
  --debug                        - Whether to log debug information.
  --all                          - Unpin a node from all groups
  --node_group GROUP             - Node group to unpin from

See 'puppet man node_manager' or 'man puppet-node_manager' for full help.

This is a breaking change because previously, unpin would unpin the node from all groups. Now it will only do all groups if --all is supplied.

tkishel commented 5 years ago

So --node_group is an ID not a Name?

WhatsARanjit commented 5 years ago

Merged.