Answers: <p>Your second link just use the official cookbook. This official cookbook still uses the LWRP syntax, so you need to check in the provider directory for the <a href="https://gitlab.com/chef-platform/gitlab-ci-runner/blob/master/providers/default.rb" rel="nofollow noreferrer">resource action code</a> -- which for register is basically just two execute commands (extract from the file linked above):</p>
  
  <pre><code>converge_by("Register runner #{new_resource.description}") do
    execute "#{env} gitlab-runner register --non-interactive #{options}"
    # giving time to gitlab-ci to manage the request
    execute "sleep #{new_resource.sleep}"
  end
  </code></pre>
  
  <p>So mostly, your exemple ends up calling the <code>gitlab-runner register</code> command with the options defined in the options hash (with a little transformation of the hash into command parameters).</p>
  
  <p>There's no 'core' chef resource to register gitlab runners out of using an <code>execute</code> resource to run the command.</p>
  
  <p>A basic example of this resource is present in the cookbook <a href="https://gitlab.com/chef-platform/gitlab-ci-runner/tree/master#default-1" rel="nofollow noreferrer">Readme</a>:</p>
  
  <pre><code>gitlab_ci_runner 'my runner' do
    options({
      registration_token: '1234567890',
      url: 'http://gitlab-ci.myinstance'
    })
  end
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2018-09-15T00:31:12.193Z
Answers: In my cookbook I have added providers/default.rb completely and gitlab_ci_runner resource  from official cookbook. But still it can able to find the resource for gitlab_ci_runner. ` NoMethodError
   -------------
   undefined method `gitlab_ci_runner' for cookbook: gitlab_runner, recipe: install_runner :Chef::Recipe` is there anything do we need to add Thanks!
Answers: DevOps
Answers: CC BY-SA 4.0
Answers: 2018-09-15T06:57:28.837Z
Answers: That's not the way to use another cookbook, you need to get this cookbook, I recommend you to follow the tutorials at https://learn.chef.io as it's too long to fit in a comment
Answers: Tensibai
Answers: CC BY-SA 4.0
Answers: 2018-09-20T18:42:25.343Z
Answers: I tried by adding providers from official cookbook but there is some issue with it.(May be some thing from my side). I have included `recipe[gitlab-ci-runner::register]` and added register recipe to my recipe and worked well. Thanks@ Tensibai
Answers: DevOps
Answers: CC BY-SA 4.0
Answers: 2018-09-14T07:35:57.743Z
Answers: 2019-06-24T07:36:38.040Z
Answers: 2019-06-24T07:36:38.040Z
Answers: Tensibai
Body: <p>We would like to automate installation of gitlab runner using chef.  we are  successful with it. Now, the Issue is regarding registering gitlab runner with chef resource.
  we have gone through chef resource. and official cookbook <a href="https://gitlab.com/chef-platform/gitlab-ci-runner" rel="nofollow noreferrer">https://gitlab.com/chef-platform/gitlab-ci-runner</a> but looks a bit complicated for us. we wonder if we have any pre-built chef resources to register gitlab runner. if yes, can we know how we can register with a example resource.
  Additionally, I have tried looking at resource <a href="https://github.com/TYPO3-cookbooks/site-gitlabcirunnertypo3org/blob/master/recipes/default.rb" rel="nofollow noreferrer">https://github.com/TYPO3-cookbooks/site-gitlabcirunnertypo3org/blob/master/recipes/default.rb</a>  </p>
  
  <pre><code>name = "#{node['fqdn']}-docker"
    gitlab_ci_runner name do
        options(
          registration_token: registration_token,
          url: node['site-gitlabcirunnertypo3org']['gitlab_url'],
          executor: 'docker',
          :'docker-image' =&gt; 'docker:1',
          :'tag-list' =&gt; ['docker']
        )
  end
  </code></pre>
  
  <p>But I dont understand how it is registering the runner. Thanks for help!</p>
  
Tags: <chef><gitlab><gitlab-ci-runner>
Title: Chef resource to register gitlab runner automatically
UserDisplayName: DevOps
ThreadText: # Chef resource to register gitlab runner automatically
  
  (Asked by: username_0 on 2018-09-14)
  
  We would like to automate installation of gitlab runner using chef. we are successful with it. Now, the Issue is regarding registering gitlab runner with chef resource.
  we have gone through chef resource. and official cookbook <https://gitlab.com/chef-platform/gitlab-ci-runner> but looks a bit complicated for us. we wonder if we have any pre-built chef resources to register gitlab runner. if yes, can we know how we can register with a example resource.
  Additionally, I have tried looking at resource <https://github.com/TYPO3-cookbooks/site-gitlabcirunnertypo3org/blob/master/recipes/default.rb>
  
  ```
  name = "#{node['fqdn']}-docker"
    gitlab_ci_runner name do
        options(
          registration_token: registration_token,
          url: node['site-gitlabcirunnertypo3org']['gitlab_url'],
          executor: 'docker',
          :'docker-image' => 'docker:1',
          :'tag-list' => ['docker']
        )
  end
  
  ```
  
  But I dont understand how it is registering the runner. Thanks for help!
  
  **Tags:** chef, gitlab, gitlab-ci-runner
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-09-14. Score: 1 | Accepted answer
  
  Your second link just use the official cookbook. This official cookbook still uses the LWRP syntax, so you need to check in the provider directory for the [resource action code](https://gitlab.com/chef-platform/gitlab-ci-runner/blob/master/providers/default.rb) -- which for register is basically just two execute commands (extract from the file linked above):
  
  ```
  converge_by("Register runner #{new_resource.description}") do
    execute "#{env} gitlab-runner register --non-interactive #{options}"
    # giving time to gitlab-ci to manage the request
    execute "sleep #{new_resource.sleep}"
  end
  
  ```
  
  So mostly, your exemple ends up calling the `gitlab-runner register` command with the options defined in the options hash (with a little transformation of the hash into command parameters).
  
  There's no 'core' chef resource to register gitlab runners out of using an `execute` resource to run the command.
  
  A basic example of this resource is present in the cookbook [Readme](https://gitlab.com/chef-platform/gitlab-ci-runner/tree/master#default-1):
  
  ```
  gitlab_ci_runner 'my runner' do
    options({
      registration_token: '1234567890',
      url: 'http://gitlab-ci.myinstance'
    })
  end
  
  ```
  
  > **Comments:**
  > **username_0**: In my cookbook I have added providers/default.rb completely and gitlab_ci_runner resource  from official cookbook. But still it can able to find the resource for gitlab_ci_runner. ` NoMethodError  -------------  undefined method `gitlab_ci_runner' for cookbook: gitlab_runner, recipe: install_runner :Chef::Recipe` is there anything do we need to add Thanks!  
  > **username_1**: That's not the way to use another cookbook, you need to get this cookbook, I recommend you to follow the tutorials at https://learn.chef.io as it's too long to fit in a comment  
  > **username_0**: I tried by adding providers from official cookbook but there is some issue with it.(May be some thing from my side). I have included `recipe[gitlab-ci-runner::register]` and added register recipe to my recipe and worked well. Thanks@ username_1  
  
  ---
  
  