Question

I followed the Chef beginner's tutorial in https://learnchef.opscode.com/quickstart/converge/ and https://learnchef.opscode.com/starter-use-cases/ntp/

I try ro add the ntp cookbook in the node's run-list.

For this, I try to run

knife node edit localhost

where localhost is the hostname, but it fails to understand the "localhost". However, the

knife bootstrap localhost

command did understand the localhost.

What am I doing wrong?

The logs are as follows:

(chef-repo_default_1380728124 is the name of the VM in VirtualBox)


$ knife edit node yannis-starter
ERROR: node: No such file or directory
ERROR: yannis-starter: No such file or directory

Administrator@PAVILION ~/chef-repo (master)
$ knife edit node vagrant
ERROR: node: No such file or directory
ERROR: vagrant: No such file or directory

Administrator@PAVILION ~/chef-repo (master)
$ knife edit node chef-repo_default_1380728124
ERROR: node: No such file or directory
ERROR: chef-repo_default_1380728124: No such file or directory

Administrator@PAVILION ~/chef-repo (master)
$ knife edit node localhost
ERROR: node: No such file or directory
ERROR: localhost: No such file or directory

Administrator@PAVILION ~/chef-repo (master)
$ knife cookbook upload --all
Uploading aliases        [0.1.0]
Uploading apache2        [1.7.0]
Uploading apt            [2.1.2]
Uploading magic_shell    [0.3.2]
Uploading ntp            [0.1.0]
Uploading starter        [1.0.0]
Uploaded all cookbooks.

Administrator@PAVILION ~/chef-repo (master)
$ cd ~/chef-repo

Administrator@PAVILION ~/chef-repo (master)
$ vagrant up --no-color
Bringing machine 'default' up with 'virtualbox' provider...
[default] VirtualBox VM is already running.

Administrator@PAVILION ~/chef-repo (master)
$ knife bootstrap localhost \
>   --ssh-user vagrant \
>   --ssh-password vagrant \
>   --ssh-port 2222 \
>   --run-list "recipe[apt],recipe[aliases],recipe[apache2],recipe[ntp]" \
>   --sudo
Bootstrapping Chef on localhost
localhost Starting Chef Client, version 11.6.0[0m
localhost
localhost resolving cookbooks for run list: ["apt", "aliases", "apache2", "ntp"][0m
localhost
localhost Synchronizing Cookbooks:[0m
localhost
localhost   - apt[0m
localhost
localhost   - aliases[0m
localhost
localhost   - magic_shell[0m
localhost
localhost   - apache2[0m
localhost
localhost   - ntp[0m
localhost
localhost Compiling Cookbooks...[0m
localhost
localhost [2013-10-03T00:12:27+00:00] WARN: Cloning resource attributes for service[apache2] from prior resource (CHEF-3
694)
localhost
localhost [2013-10-03T00:12:27+00:00] WARN: Previous service[apache2]: /var/chef/cache/cookbooks/apache2/recipes/default
.rb:24:in `from_file'
localhost
localhost [2013-10-03T00:12:27+00:00] WARN: Current  service[apache2]: /var/chef/cache/cookbooks/apache2/recipes/default
.rb:221:in `from_file'
localhost
localhost Converging 48 resources[0m
localhost
localhost Recipe: apt::default[0m
localhost
localhost   * execute[apt-get-update] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost   * execute[apt-get update] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost   * execute[apt-get autoremove] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost   * execute[apt-get autoclean] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost   * package[update-notifier-common] action install[0m
localhost  (up to date)[0m
localhost
localhost   * execute[apt-get-update-periodic] action run[0m
localhost  (skipped due to only_if)[0m
localhost
localhost   * directory[/var/cache/local] action create[0m
localhost  (up to date)[0m
localhost
localhost   * directory[/var/cache/local/preseeding] action create[0m
localhost  (up to date)[0m
localhost
localhost Recipe: aliases::default[0m
localhost
localhost   * magic_shell_alias[h] action add[0m
localhost Recipe: <Dynamically Defined Resource>[0m
localhost
localhost   * file[/etc/profile.d/h.sh] action create[0m
localhost  (up to date)[0m
localhost
localhost  (up to date)[0m
localhost
localhost   * file[/etc/profile.d/h.sh] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost Recipe: aliases::default[0m
localhost
localhost   * magic_shell_alias[sites] action add[0m
localhost Recipe: <Dynamically Defined Resource>[0m
localhost
localhost   * file[/etc/profile.d/sites.sh] action create[0m
localhost  (up to date)[0m
localhost
localhost  (up to date)[0m
localhost
localhost   * file[/etc/profile.d/sites.sh] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost Recipe: aliases::default[0m
localhost
localhost   * magic_shell_environment[EDITOR] action add[0m
localhost Recipe: <Dynamically Defined Resource>[0m
localhost
localhost   * file[/etc/profile.d/EDITOR.sh] action create[0m
localhost  (up to date)[0m
localhost
localhost  (up to date)[0m
localhost
localhost   * file[/etc/profile.d/EDITOR.sh] action nothing[0m
localhost  (skipped due to action :nothing)[0m
localhost
localhost Recipe: apache2::default[0m
localhost
localhost   * package[apache2] action install[0m
localhost  (up to date)[0m
localhost
localhost   * service[apache2] action enable[0m
localhost  (up to date)[0m
localhost
localhost   * directory[/etc/apache2/ssl] action create[0m
localhost  (up to date)[0m
localhost
localhost   * directory[/etc/apache2/conf.d] action create[0m
localhost  (up to date)[0m
localhost
localhost   * directory[/var/cache/apache2] action create[0m
localhost  (up to date)[0m
localhost
localhost   * template[/etc/sysconfig/httpd] action create[0m
localhost  (skipped due to only_if)[0m
localhost
localhost   * template[apache2.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * template[apache2-conf-security] action create[0m
localhost  (up to date)[0m
localhost
localhost   * template[apache2-conf-charset] action create[0m
localhost  (up to date)[0m
localhost
localhost   * template[/etc/apache2/ports.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * template[/etc/apache2/sites-available/default] action create[0m
localhost  (up to date)[0m
localhost
localhost Recipe: apache2::mod_status[0m
localhost
localhost   * template[/etc/apache2/mods-available/status.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod status] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_alias[0m
localhost
localhost   * template[/etc/apache2/mods-available/alias.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod alias] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_auth_basic[0m
localhost
localhost   * execute[a2enmod auth_basic] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_authn_file[0m
localhost
localhost   * execute[a2enmod authn_file] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_authz_default[0m
localhost
localhost   * execute[a2enmod authz_default] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_authz_groupfile[0m
localhost
localhost   * execute[a2enmod authz_groupfile] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_authz_host[0m
localhost
localhost   * execute[a2enmod authz_host] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_authz_user[0m
localhost
localhost   * execute[a2enmod authz_user] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_autoindex[0m
localhost
localhost   * template[/etc/apache2/mods-available/autoindex.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod autoindex] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_dir[0m
localhost
localhost   * template[/etc/apache2/mods-available/dir.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod dir] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_env[0m
localhost
localhost   * execute[a2enmod env] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_mime[0m
localhost
localhost   * template[/etc/apache2/mods-available/mime.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod mime] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_negotiation[0m
localhost
localhost   * template[/etc/apache2/mods-available/negotiation.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod negotiation] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::mod_setenvif[0m
localhost
localhost   * template[/etc/apache2/mods-available/setenvif.conf] action create[0m
localhost  (up to date)[0m
localhost
localhost   * execute[a2enmod setenvif] action run[0m
localhost  (skipped due to not_if)[0m
localhost
localhost Recipe: apache2::default[0m
localhost
localhost   * execute[a2dissite default] action run[0m
localhost  (skipped due to only_if)[0m
localhost
localhost   * service[apache2] action start[0m
localhost  (up to date)[0m
localhost
localhost Recipe: ntp::default[0m
localhost
localhost   * package[ntp] action install[0m
localhost [32m
localhost
localhost     - install version 1:4.2.6.p3+dfsg-1ubuntu3.1 of package ntp[0m
localhost
localhost [0m
localhost
localhost   * template[/etc/ntp.conf] action create[0m
localhost [32m
localhost
localhost     - update content in file /etc/ntp.conf from 4eb9a0 to f4bd23[0m
localhost [37m
localhost
localhost         --- /etc/ntp.conf
localhost
localhost 2012-06-05 20:12:22.000000000 +0000[0m
localhost [37m
localhost
localhost         +++ /tmp/chef-rendered-template20131003-3352-zv5vk7
localhost
localhost 2013-10-03 00:12:32.846736126 +0000[0m
localhost [37m
localhost
localhost         @@ -1,55 +1,12 @@[0m
localhost [37m
localhost
localhost         -# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -driftfile /var/lib/ntp/ntp.drift[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -# Enable this if you want statistics to be logged.[0m
localhost [37m
localhost
localhost         -#statsdir /var/log/ntpstats/[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -statistics loopstats peerstats clockstats[0m
localhost [37m
localhost
localhost         -filegen loopstats file loopstats type day enable[0m
localhost [37m
localhost
localhost         -filegen peerstats file peerstats type day enable[0m
localhost [37m
localhost
localhost         -filegen clockstats file clockstats type day enable[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -# Specify one or more NTP servers.[0m
localhost [37m
localhost
localhost         -[0m
localhost [37m
localhost
localhost         -# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board[0m
localhost [37m
localhost
localhost         -# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for[0m
localhost [37m
localhost
localhost         -# more information.[0m
localhost [37m
localhost
localhost         -server 0.ubuntu.pool.ntp.org[0m
localhost [37m
localhost
localhost         -server 1.ubuntu.pool.ntp.org[0m[37m
localhost         -server 2.ubuntu.pool.ntp.org[0m[37m
localhost         -server 3.ubuntu.pool.ntp.org[0m[37m
localhost
localhost         -[0m[37m
localhost
localhost         -# Use Ubuntu's ntp server as a fallback.[0m[37m
localhost
localhost         -server ntp.ubuntu.com[0m[37m
localhost         -[0m[37m
localhost
localhost         -# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for[0m[37m
localhost         -# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>[0m[37m
localhost         -# might also be helpful.[0m[37m
localhost         -#[0m[37m
localhost         -# Note that "restrict" applies to both servers and clients, so a configuration[0m[37m
localhost         -# that might be intended to block requests from certain clients could also end[0m[37m
localhost         -# up blocking replies from your own upstream servers.[0m[37m
localhost         -[0m[37m
localhost         -# By default, exchange time with everybody, but don't allow configuration.[0m[37m
localhost
localhost         -restrict -4 default kod notrap nomodify nopeer noquery[0m[37m
localhost
localhost         -restrict -6 default kod notrap nomodify nopeer noquery[0m[37m
localhost         -[0m[37m
localhost
localhost         -# Local users may interrogate the ntp server more closely.[0m[37m
localhost
localhost         -restrict 127.0.0.1[0m[37m
localhost         -restrict ::1[0m[37m
localhost
localhost         -[0m[37m
localhost
localhost         -# Clients from this (example!) subnet have unlimited access, but only if[0m[37m
localhost
localhost         -# cryptographically authenticated.[0m[37m
localhost
localhost         -#restrict 192.168.123.0 mask 255.255.255.0 notrust[0m[37m
localhost         -[0m[37m
localhost         -[0m[37m
localhost         -# If you want to provide time to your local subnet, change the next line.[0m[37m
localhost         -# (Again, the address is an example only.)[0m[37m
localhost         -#broadcast 192.168.123.255[0m[37m
localhost
localhost         -[0m[37m
localhost         -# If you want to listen to time broadcasts on your local subnet, de-comment the[0m[37m
localhost
localhost         -# next lines.  Please do this only if you trust everybody on the network![0m[37m
localhost         -#disable auth[0m[37m
localhost
localhost         -#broadcastclient[0m[37m
[0m[37m         +# This file was generated by Chef for 'yannis-starter'.
localhost
[0m[37m         +# Do NOT edit this file by hand!
[0m[37m         +
localhost
[0m[37m         +restrict default kod nomodify notrap nopeer noquery
localhost
[0m[37m         +restrict -6 default kod nomodify notrap nopeer noquery
localhost
[0m[37m         +restrict 127.0.0.1
localhost
[0m[37m         +restrict -6 ::1
localhost
[0m[37m         +server '0.pool.ntp.org'
[0m[37m         +server  127.127.1.0     # local clock
[0m[37m         +driftfile /var/lib/ntp/drift
[0m[37m         +keys /etc/ntp/keys
[0mlhost         +
localhost [0m
localhost
localhost   * service[ntp] action enable[0m
localhost  (up to date)[0m
localhost
localhost   * service[ntp] action start[0m
localhost  (up to date)[0m
localhost
localhost   * service[ntp] action restart[0m
localhost [32m
localhost
localhost     - restart service service[ntp][0m
localhost
localhost [0m
localhost
localhost Chef Client finished, 3 resources updated[0m
localhost

Administrator@PAVILION ~/chef-repo (master)
$ knife node edit localhost
ERROR: The object you are looking for could not be found
Response: node 'localhost' not found

Administrator@PAVILION ~/chef-repo (master)
$ vagrant ssh
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

Last login: Thu Oct  3 00:12:18 2013 from 10.0.2.2
vagrant@yannis-starter:~$ hostname
yannis-starter
vagrant@yannis-starter:~$ ping yannis-starter
PING yannis-starter (127.0.1.1) 56(84) bytes of data.
64 bytes from yannis-starter (127.0.1.1): icmp_req=1 ttl=64 time=0.032 ms
64 bytes from yannis-starter (127.0.1.1): icmp_req=2 ttl=64 time=0.027 ms
64 bytes from yannis-starter (127.0.1.1): icmp_req=3 ttl=64 time=0.032 ms

--- yannis-starter ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1998ms
rtt min/avg/max/mdev = 0.027/0.030/0.032/0.005 ms
vagrant@yannis-starter:~$ exit
logout
Connection to 127.0.0.1 closed.

Administrator@PAVILION ~/chef-repo (master)
$ ping yannis-starter
Ping request could not find host yannis-starter. Please check the name and try again.

Administrator@PAVILION ~/chef-repo (master)
$ vagrant ssh
Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.5.0-23-generic i686)

 * Documentation:  https://help.ubuntu.com/

Last login: Thu Oct  3 00:20:06 2013 from 10.0.2.2
vagrant@yannis-starter:~$ ifconfig
eth0      Link encap:Ethernet  HWaddr 08:00:27:d0:18:0b
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fed0:180b/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:27212 errors:0 dropped:0 overruns:0 frame:0
          TX packets:14893 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:32931491 (32.9 MB)  TX bytes:1452344 (1.4 MB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:6 errors:0 dropped:0 overruns:0 frame:0
          TX packets:6 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:504 (504.0 B)  TX bytes:504 (504.0 B)

vagrant@yannis-starter:~$ exit
logout
Connection to 127.0.0.1 closed.

Administrator@PAVILION ~/chef-repo (master)
Was it helpful?

Solution

knife bootstrap takes a hostname or IP address as a parameter. In your case, localhost will resolve to 127.0.0.1 and knife will bootstrap your local machine.

knife node edit, on the other hand, takes a node's name for its parameter.

If you haven't set the name attribute during bootstrap, it will default to your machine's hostname -- you can get it by issuing hostname on the shell, or just use knife node edit $(hostname).

If that doesn't work, try doing a search on the Chef server for all your nodes with knife search 'name:*'. Find your local host there and use its name with knife node edit.

OTHER TIPS

@cbl: Thank you for your help. knife node edit $(hostname) did not help because it tried to talk again to the Chef workstation (=localhost) and not to the node. But by searching with knife search 'name:*' I found the node name. The solution is bellow:


$ echo $(hostname)
pavilion

Administrator@PAVILION ~/chef-repo (master)
$ knife node edit $(hostname)
ERROR: The object you are looking for could not be found
Response: node 'pavilion' not found

Administrator@PAVILION ~/chef-repo (master)
$ knife search 'name:*'
1 items found

Node Name:   yannis-starter
Environment: _default
FQDN:        yannis-starter
IP:          10.0.2.15
Run List:    recipe[apt], recipe[aliases], recipe[apache2], recipe[ntp]
Roles:
Recipes:     apt, aliases, apache2, ntp
Platform:    ubuntu 12.04
Tags:


Administrator@PAVILION ~/chef-repo (master)
$ knife node edit yannis-starter
Node not updated, skipping node save

Administrator@PAVILION ~/chef-repo (master)
$
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top