# \[RESOLVED\] One time runlist during bootstrap

**URL:** <https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573>\
**Category:** Chef Infra (archive)\
**Created:** [March 14, 2017, 2:51am UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573 "2017-03-14T02:51:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [March 14, 2017, 2:51am UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/1 "2017-03-14T02:51:49Z")

</div>

I feel like this has been asked before, but I can’t seem to find the answer I am looking for, or in fact an answer (even if it isn’t what I want to hear).

I have a cookbook that does organisation specific config of our nodes during bootstrap. I am wanting to know if there is a way to supply a one time runlist during bootstrap so that the initial runlist specified isn’t permanent? I see there used to be a `-o` option that could be used as an override, but the `knife bootstrap` command doesn’t like this anymore ☹

Thanks for your help in advance!

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [March 14, 2017, 8:09pm UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/2 "2017-03-14T20:09:18Z")

</div>

This is most commonly done by having the cookbook you use during bootstrap modify the run list.

---

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [March 14, 2017, 9:53pm UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/3 "2017-03-14T21:53:17Z")

</div>

So, interestingly, having the cookbook do it, is not working. I can see the command runs as expected, within the cookbook with out any issues.

Here is the output of the batch resource ``

```
batch[remove_bootstrap_runlist] action run[2017-03-15T10:37:37+13:00] INFO: Processing 
batch[remove_bootstrap_runlist] action run (mycookbook::default line 69)

    [execute]
              C:\>knife node run_list remove windows-test-01 'recipe[mycookbook]' -c c:\chef\client.rb
              windows-test-01:
                run_list:
    [2017-03-15T10:37:40+13:00] INFO: batch[remove_mycookbook_runlist] ran successfully

```

Here is the batch resource I am trying to use within the cookbook.

```
  batch 'remove_bootstrap_runlist' do
    code <<-EOH
      knife node run_list remove #{nodename} 'recipe[mycookbook]' -c c:\\chef\\client.rb
    EOH
  end

```

Now, if I run the batch resource from the node’s `cmd` independent of the cookbook using `knife`, it all runs as expected and edits the nodes `run_list`

```
knife node run_list remove windows-test-01 'recipe[mycookbook]' -c c:\\chef\\client.rb

```

Here are the server/client versions I am using.  
`chef-server 12.12`  
`Chef-client 12.19.36`

---

<div class="post-metadata">

**Author:** ![kallistec](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kallistec/32/23_2.png) [@kallistec](https://discourse.chef.io/u/kallistec)\
**Post date:** [March 15, 2017, 6:24pm UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/4 "2017-03-15T18:24:03Z")

</div>

> [@svucich](#):
>
> Here is the batch resource I am trying to use within the cookbook.

This won't work. `knife` will successfully edit the node, but then when the in-progress Chef Client run completes, it will save the node and overwrite what `knife` did.

What you want to do instead is modify the run list on the node object in Chef Client so that the run list you want gets saved by Chef at the end of the run. The basic code is `node.run_list("recipe[foo::bar]", "recipe[baz::qux]", ...)` though you may need to stuff that in a ruby block resource to get the compile time/converge time stuff right, depending on how you compute the run list.

---

<div class="post-metadata">

**Author:** ![svucich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/svucich/32/1717_2.png) [@svucich](https://discourse.chef.io/u/svucich)\
**Post date:** [March 16, 2017, 3:31am UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/5 "2017-03-16T03:31:44Z")

</div>

Thanks for that. Here is what I ended up doing, just incase another noob (like me) requires a more full answer:

```
# Removes the recipe 'my_recipe' from the nodes run list
ruby_block 'remove_my_recipe' do
  block do
    node.run_list.remove('recipe[my_recipe]')
  end
  action :run
end
```

---

<div class="post-metadata">

**Author:** ![joerod](https://avatars.discourse-cdn.com/v4/letter/j/df788c/32.png) [@joerod](https://discourse.chef.io/u/joerod)\
**Post date:** [April 13, 2017, 6:51pm UTC](https://discourse.chef.io/t/resolved-one-time-runlist-during-bootstrap/10573/6 "2017-04-13T18:51:22Z")

</div>

Thanks for sharing this helped me!
