title: Can I use cloud-init to install and configure chef, but not actually run it?
body: <p>I have a working CloudFormation template, with user data and cloud-init, connecting and building successfully to a hosted Chef server. I'm using Ubuntu 12.04 on an AWS EC2 stock image.</p>
  
  <p>For my own purposes I would like to continue to do this, but</p>
  
  <p>1) <strong><em>Not</em></strong> configure Chef to run as a service, only run on demand ("sudo chef-client")</p>
  
  <p>...alternatively, or to complement this</p>
  
  <p>2) perform the entire Chef install/config as before, but <strong>only run once</strong>, not as a service</p>
  
  <p>I couldn't find the appropriate hooks, if any to achieve this wading through cloud-init examples. I wondered if there was some setting for Chef to allow for this use case? I tried using update-rc.d to disable chef-client but this didn't work due to it already being running.</p>
  
  <p>Here is the fragment of the userdata in the CF template associated with the EC2 instance:</p>
  
  <pre><code>#cloud-config
  
  resize_rootfs: true
  apt_update: true
  byobu_by_default: disable
  manage_etc_hosts: false
  disable_root: true
  timezone: Europe/London
  package_upgrade: true
  package_reboot_if_required: true
  
  apt_sources:
    - source: "deb http://apt.opscode.com/ $RELEASE-0.10 main"
      key: |
        -----BEGIN PGP PUBLIC KEY BLOCK-----
        Version: GnuPG v1.4.9 (GNU/Linux)
        xxxx truncated xxxxx
        -----END PGP PUBLIC KEY BLOCK-----
  
  chef:
    install_type: packages
    server_url: xxxxxx
    node_name: xxxxx
    validation_name: xxxxxx
    validation_key: |
      -----BEGIN RSA PRIVATE KEY-----
      xxxx truncated xxxxx
      -----END RSA PRIVATE KEY-----
    run_list:
      - role[my-server]
    environment: production
  
  output: {all: '| tee -a /var/log/cloud-init-output.log'}
  </code></pre>