打包程序脚本错误必须指定脚本文件或内联脚本

时间:2019-04-23 11:04:19

标签: amazon-web-services ansible packer

我的打包程序脚本出错

  {
"variables":
{
"aws_access_key": "",
"aws_secret_key": "",
"revision": "0",
"ansible_host":""
},
"builders":[{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "region": "us-east-2",
    "instance_type": "t2.micro",
    "source_ami": "ami-09e1c6dd3bd60cf2e",
    "source_ami_filter": {
        "filters": {
          "virtualization-type": "hvm",
          "name": "ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*",
          "root-device-type": "ebs"
  }},
    "ssh_username": "ubuntu",
    "ami_name":"honebackend {{ isotime | clean_ami_name }}"
}],
"provisioners":[
    {
    "type":"shell",
    "script":"scripts/ssh_agent.sh"
    },
    {
    "type": "shell",
    "execute_command": "mkdir /var/apps"
    },
    {
    "type":"ansible",
    "extra_arguments": [ "-vvv --extra-vars 'ansible_host={{user `host`}} ../ansible/hosts.ini ansible_python_interpreter=/usr/bin/python3"],
    "inventory_file": "../ansible/hosts.ini",
    "playbook_file":"../ansible/nodejs.yml"
    }

]

}

运行以下命令后:

  packer build -debug -var 'aws_access_key=XXXXXXXXXXXXXXXXXXXXXXX' -var
    'aws_secret_key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'      packer.json

实际结果是:     启用调试模式。构建将不会并行化。     亚马逊-ebs输出将采用这种颜色。

1 error(s) occurred:

* Either a script file or inline script must be specified.

我在这里做错了什么?

1 个答案:

答案 0 :(得分:1)

错误提示:

#include <netinet/in.h>
#include <string>
#include <sys/socket.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <cerrno>
#include <cstring>
#include <iostream>

using namespace std;

int main(){


    int port = 10000;
    string ip_addr = "127.0.0.1";
    int domain = AF_INET;
    int type = SOCK_STREAM;
    int protocol = 0;

    int stopCondition = 0xFFFFFFFF;


    int socketHandle;
    struct sockaddr_in address;

    int clientSocketHandle;
    struct sockaddr_in clientAddress;
    size_t clientAddressSize;

    int buffer;


   if((socketHandle=socket(domain,type,protocol))<0)
        cout<<strerror(errno);

    address.sin_family = domain;
    inet_pton(domain,ip_addr.c_str(),&address.sin_addr);
    address.sin_port=htons(port);


    if((bind(socketHandle,(struct sockaddr *)&address,sizeof(address)))<0)
        cout<<strerror(errno);


    if (listen(socketHandle, 1) < 0)
        cout << strerror(errno);


    if ((clientSocketHandle = accept(socketHandle, (struct sockaddr *) &clientAddress, (socklen_t *) &clientAddressSize)) < 0)
        cout << strerror(errno);


    do {

        if (recv(clientSocketHandle, &buffer, sizeof(int), 0) > 0)
            cout<<buffer<<endl;

    } while (buffer != stopCondition);


    if(shutdown(clientSocketHandle,SHUT_RDWR)<0)
        cout<<strerror(errno);


    if(shutdown(socketHandle,SHUT_RDWR)<0)
        cout<<strerror(errno);

    return 0;
}

真的应该是:

{
  "type": "shell",
  "execute_command": "mkdir /var/apps"
 },