You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: itamae_plugin.rb
    path of file: ./repos/barcelona/lib/barcelona/plugins
    
    the code of the file until where you have to start completion: # Itamae plugin
# This plugin installs Itamae and apply the specified recipe on initialize
# Usage: bcn district put-plugin essa-test itamae -a recipe_url=s3://barcelona-essa-test-1573458106/itamae_recipes/recipe.tar.gz

module Barcelona
  module Plugins
    class ItamaePlugin < Base
      def on_container_instance_user_data(_instance, user_data)
        install_itamae(user_data)
        apply_itamae_recipe(user_data, attributes['recipe_url'], 'barcelona_container')
        user_data
      end

      def on_network_stack_template(_stack, template)
     
    
      def apply_itamae_recipe(user_data, recipe_url, role)
        archive = Pathname.new(URI.parse(recipe_url).path).basename
        user_data.add_file("/usr/local/bin/apply_itamae.sh", "root:root", "755", <<~EOS)
          #!/bin/bash
          set -ex
          # download the recipe
          mkdir /root/itamae && cd /root/itamae
          aws s3 cp #{recipe_url} .
          tar zxvf #{archive}
          # Make sudo usable without tty
          sed -i -e "s/^ *Defaults *requiretty/# Defaults requiretty/" /etc/sudoers
          # apply itamae recipe
          itamae local roles/#{role}.rb -y nodes/#{role}.yml -l info > /var/log/itamae.log
        EOS

        user_data.run_commands += [
          '/usr/local/bin/apply_itamae.sh'
        ]
      end
    end