chef [SOLVED]: How to create a user and group in chef without 'cloning resource' warning

chef [SOLVED]: How to create a user and group in chef without 'cloning resource' warning

Home Forums Automation Tools Chef Tutorials chef [SOLVED]: How to create a user and group in chef without 'cloning resource' warning

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #197363

    Cloudy Point
    Keymaster

    QuestionQuestion

    I recently used following recipe to create a specific user, group:

    sysadmin = data_bag_item('users','sysadmin')
    
    group 'sysadmin' do
      action :create
      gid sysadmin['gid'].to_i
    end
    
    user 'sysadmin' do
      uid sysadmin['uid'].to_i
      gid sysadmin['gid'].to_i
      manage_home true
      shell sysadmin['shell']
      action :create
    end
    
    group 'sysadmin' do
      action :modify
      members 'sysadmin'
      append true
    end
    

    And get following warnings:

      Cloning resource attributes for group[sysadmin] from prior resource
    Previous group[sysadmin]: /var/chef/cache/cookbooks/initialubuntu/recipes/sysadmin_user.rb:16:in `from_file'
    Current  group[sysadmin]: /var/chef/cache/cookbooks/initialubuntu/recipes/sysadmin_user.rb:29:in `from_file' at 1 location:
    

    Chef cannot create a user with gid of non-existent system group.

    How to merge group resources into one?

    #197364

    Cloudy Point
    Keymaster

    Accepted AnswerAnswer

    You would have to rename one of them, for example you could rename the second one:

    group 'append sysadmin' do
      group_name 'sysadmin'
      action :modify
      members 'sysadmin'
      append true
    end
    

    Alternatively if you upgrade to Chef 13, cloning has been removed at long last so these warnings are impossible now.

    Source: https://stackoverflow.com/questions/46419422/how-to-create-a-user-and-group-in-chef-without-cloning-resource-warning
    Author: coderanger
    Creative Commons License
    This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.