title: How do I register/reregister a Gitlab Runner using a pre-made config.toml?
body: <p>I recently wanted to move a Gitlab runner that I had set up for my self-hosted Gitlab instance from being a project runner (i.e. running jobs only for a project) to being a group runner (so it could also run jobs for other projects in the same group). I wanted to retain the <code>/etc/gitlab-runner/config.toml</code> settings that I had painstakingly hand-written.</p>
  <p>Luckily I backed up <code>config.toml</code>, because <code>sudo gitlab-runner unregister -t ... -u ...</code> deleted the whole configuration from <code>config.toml</code>.</p>
  <p>In order to get the same config registered under the group instead of the project, I had to:</p>
  <ol>
  <li>Register the runner in a paused state with a dummy configuration, with the group's registration token:</li>
  </ol>
  <pre><code>sudo gitlab-runner register \
    --non-interactive \
    --url &lt;URL HERE&gt;
    --registration-token &lt;TOKEN HERE&gt; \
    --executor docker \
    --docker-image docker:dind \
    --paused
  </code></pre>
  <ol start="2">
  <li><p>Go into the new <code>config.toml</code> that this created and copy the runner's individual runner token.</p>
  </li>
  <li><p>Overwrite <code>config.toml</code> with my desired configuration.</p>
  </li>
  <li><p>Edit the <code>config.toml</code> and plug in the new individual runner token.</p>
  </li>
  <li><p>Start the Gitlab runner service (<code>sudo systemctl start gitlab-runner</code>).</p>
  </li>
  <li><p>Unpause the runner in the Gitlab web UI.</p>
  </li>
  </ol>
  <p>Even after doing all this, the Gitlab instance still sees the runner under the name it registered with in the dummy config, rather than the name in the <code>config.toml</code>.</p>
  <p>Trying the <code>--config</code> option to <code>gitlab-runner register</code> didn't work at all; I think that just tells it where to <em>save</em> the config. It still prompted me for new settings to use instead of reading from the <code>config.toml</code> I pointed it at.</p>
  <p>The Gitlab documentation on runner registration is all written around one shot <code>gitlab-runner register</code> commands with loads of options on them that essentially specify the whole config on the command line. I really don't want to translate my <code>config.toml</code> manually into a command line that turns around and rebuilds it (minus any comments, of course).</p>
  <p>I can't believe that this is really the right workflow to re-register a runner with a new project/group/Gitlab instance, or to create a copy of a runner from a saved config. What am I missing here? How can I create a new Gitlab runner from an existing <code>config.toml</code> file?</p>