Unable to create instance using wordpress template:openstack heat

Asked by Malleshi C N

Hello team ,
I am unable to create a stack using wordpress template, getting below error

2014-02-20 10:42:45.519 905 TRACE heat.engine.resource resp, body = self.request(url, method, **kwargs)
2014-02-20 10:42:45.519 905 TRACE heat.engine.resource File "/usr/lib/python2.7/dist-packages/novaclient/client.py", line 189, in request
2014-02-20 10:42:45.519 905 TRACE heat.engine.resource raise exceptions.from_response(resp, body, url, method)
2014-02-20 10:42:45.519 905 TRACE heat.engine.resource BadRequest: Multiple possible networks found, use a Network ID to be more specific. (HTTP 400) (Request-ID: req-73955d36-fd14-463f-a659-e0dd80c01b8b)
2014-02-20 10:42:45.519 905 TRACE heat.engine.resource
2014-02-20 10:42:45.544 905 WARNING heat.engine.service [-] Stack create failed, status FAILED

Do I need to add my network ID and subnet ID details in the template...?
I am using below template

{
  "AWSTemplateFormatVersion" : "2010-09-09",

  "Description" : "AWS CloudFormation Sample Template WordPress_Single_Instance: WordPress is web software you can use to create a beautiful website or blog. This template installs a single-instance WordPress deployment using a local MySQL database to store the data.",

  "Parameters" : {

    "KeyName" : {
      "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
      "Type" : "String"
    },

    "InstanceType" : {
      "Description" : "WebServer EC2 instance type",
      "Type" : "String",
      "Default" : "m1.small",
      "AllowedValues" : [ "m1.tiny", "m1.small", "m1.medium", "m1.large", "m1.xlarge" ],
      "ConstraintDescription" : "must be a valid EC2 instance type."
    },

    "DBName": {
      "Default": "wordpress",
      "Description" : "The WordPress database name",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "64",
      "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
      "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
    },

    "DBUsername": {
      "Default": "admin",
      "NoEcho": "true",
      "Description" : "The WordPress database admin account username",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "16",
      "AllowedPattern" : "[a-zA-Z][a-zA-Z0-9]*",
      "ConstraintDescription" : "must begin with a letter and contain only alphanumeric characters."
    },

    "DBPassword": {
      "Default": "admin",
      "NoEcho": "true",
      "Description" : "The WordPress database admin account password",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "41",
      "AllowedPattern" : "[a-zA-Z0-9]*",
      "ConstraintDescription" : "must contain only alphanumeric characters."
    },

    "DBRootPassword": {
      "Default": "admin",
      "NoEcho": "true",
      "Description" : "Root password for MySQL",
      "Type": "String",
      "MinLength": "1",
      "MaxLength": "41",
      "AllowedPattern" : "[a-zA-Z0-9]*",
      "ConstraintDescription" : "must contain only alphanumeric characters."
    },
    "LinuxDistribution": {
      "Default": "F17",
      "Description" : "Distribution of choice",
      "Type": "String",
      "AllowedValues" : [ "cirros", "F17", "U10", "RHEL-6.1", "RHEL-6.2", "RHEL-6.3" ]
    }
  },

  "Mappings" : {
    "AWSInstanceType2Arch" : {
      "m1.tiny" : { "Arch" : "32" },
      "m1.small" : { "Arch" : "64" },
      "m1.medium" : { "Arch" : "64" },
      "m1.large" : { "Arch" : "64" },
      "m1.xlarge" : { "Arch" : "64" }
    },
    "DistroArch2AMI": {
      "cirros" : { "32" : "cirros-i386-cfntools", "64" : "cirros-x86_64-cfntools" },
      "F17" : { "32" : "F17-i386-cfntools", "64" : "F17-x86_64-cfntools" },
      "U10" : { "32" : "U10-i386-cfntools", "64" : "U10-x86_64-cfntools" },
      "RHEL-6.1" : { "32" : "rhel61-i386-cfntools", "64" : "rhel61-x86_64-cfntools" },
      "RHEL-6.2" : { "32" : "rhel62-i386-cfntools", "64" : "rhel62-x86_64-cfntools" },
      "RHEL-6.3" : { "32" : "rhel63-i386-cfntools", "64" : "rhel63-x86_64-cfntools" }
    }
  },

  "Resources" : {
    "WikiDatabase": {
      "Type": "AWS::EC2::Instance",
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
            "packages" : {
              "yum" : {
                "mysql" : [],
                "mysql-server" : [],
                "httpd" : [],
                "wordpress" : []
              }
            },
            "services" : {
              "systemd" : {
                "mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
                "httpd" : { "enabled" : "true", "ensureRunning" : "true" }
              }
            }
          }
        }
      },
      "Properties": {
        "ImageId" : { "Fn::FindInMap" : [ "DistroArch2AMI", { "Ref" : "LinuxDistribution" },
                          { "Fn::FindInMap" : [ "AWSInstanceType2Arch", { "Ref" : "InstanceType" }, "Arch" ] } ] },
        "InstanceType" : { "Ref" : "InstanceType" },
        "KeyName" : { "Ref" : "KeyName" },
        "UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [
          "#!/bin/bash -v\n",
          "/opt/aws/bin/cfn-init\n",
          "# Setup MySQL root password and create a user\n",
          "mysqladmin -u root password '", { "Ref" : "DBRootPassword" }, "'\n",
          "cat << EOF | mysql -u root --password='", { "Ref" : "DBRootPassword" }, "'\n",
          "CREATE DATABASE ", { "Ref" : "DBName" }, ";\n",
          "GRANT ALL PRIVILEGES ON ", { "Ref" : "DBName" }, ".* TO \"", { "Ref" : "DBUsername" }, "\"@\"localhost\"\n",
          "IDENTIFIED BY \"", { "Ref" : "DBPassword" }, "\";\n",
          "FLUSH PRIVILEGES;\n",
          "EXIT\n",
          "EOF\n",
          "sed -i \"/Deny from All/d\" /etc/httpd/conf.d/wordpress.conf\n",
          "sed -i \"s/Require local/Require all granted/\" /etc/httpd/conf.d/wordpress.conf\n",
          "sed --in-place --e s/database_name_here/", { "Ref" : "DBName" }, "/ --e s/username_here/", { "Ref" : "DBUsername" }, "/ --e s/password_here/", { "Ref" : "DBPassword" }, "/ /usr/share/wordpress/wp-config.php\n",
          "systemctl restart httpd.service\n"
        ]]}}
      }
    }
  },

  "Outputs" : {
    "WebsiteURL" : {
      "Value" : { "Fn::Join" : ["", ["http://", { "Fn::GetAtt" : [ "WikiDatabase", "PublicIp" ]}, "/wordpress"]] },
      "Description" : "URL for Wordpress wiki"
    }
  }
}

please let me know , as there is no network info mentioned in this template

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Heat Edit question
Assignee:
No assignee Edit question
Solved by:
Zane Bitter
Solved:
Last query:
Last reply:
Revision history for this message
Best Zane Bitter (zaneb) said :
#1
Revision history for this message
Malleshi C N (malleshicn) said :
#2

Hi Zane,

I have added below lines to my template

"SubnetId" : {
        "Default" :"heat_key",
          "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
          "Type" : "String"
        },

   "PrivateNetworkId" : {
        "Default" :"network",
          "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
          "Type" : "String"
       },

   "PublicNetworkId" : {
        "Default" :"publicnetwork",
          "Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
          "Type" : "String"
       },

and in aws-environ.yaml

parameters:
  InstanceType: m1.medium
  KeyName: heat_key
  PrivateNetworkId: ad5a1e6c-24b7-4190-b4e7-6e4f19b046ce
  PublicNetworkId: fbfc3fa8-473b-40fa-89e8-8c7a1acb0d0b
  SubnetId: 69b3ddd9-b092-4361-b541-4f171c736a9d

but still my log messages showing

9, in request
2014-02-21 03:55:59.406 905 TRACE heat.engine.resource raise exceptions.from_response(resp, body, url, method)
2014-02-21 03:55:59.406 905 TRACE heat.engine.resource BadRequest: Multiple possible networks found, use a Network ID to be more specific. (HTTP 400) (Request-ID: req-3be9dcde-d27b-4d1b-a066-7d622aba2ad0)
2014-02-21 03:55:59.406 905 TRACE heat.engine.resource
2014-02-21 03:55:59.431 905 WARNING heat.engine.service [-] Stack create failed, status FAILED

below is mynetwork-details:

root@network-node:/home/oss# neutron net-list
+--------------------------------------+--------------+------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+--------------+------------------------------------------------------+
| ad5a1e6c-24b7-4190-b4e7-6e4f19b046ce | my_net_proj | 69b3ddd9-b092-4361-b541-4f171c736a9d 50.50.x.x/24 |
| fbfc3fa8-473b-40fa-89e8-8c7a1acb0d0b | my_ext_net | 93055862-88ea-43e8-bffb-7c209cfa9399 x.x.x.x/24 |
+--------------------------------------+--------------+------------------------------------------------------+
root@network-node:/home/oss# neutron subnet-list
+--------------------------------------+------+-----------------+------------------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+------+-----------------+------------------------------------------------------+
| 69b3ddd9-b092-4361-b541-4f171c736a9d | | 50.50.x.x/24 | {"start": "50.50.x.x", "end": "50.50.x.x"} |
| 93055862-88ea-43e8-bffb-7c209cfa9399 | | x.x.x.0/24 | {"start": "x.x.x.1", "end": "x.x.x.4"} |
+--------------------------------------+------+-----------------+------------------------------------------------------+
root@network-node:/home/oss#

Revision history for this message
Zane Bitter (zaneb) said :
#3

The answer on ask.openstack is regrettably not as clear as it could be, but basically you are missing step 2 - now that you have the data (via the parameter), you have to use it:

...
"Resources" : {
    "WikiDatabase": {
      "Type": "AWS::EC2::Instance",
      ...
      "Properties": {
        ...
        "SubnetId": {"Ref": "SubnetId"},
        ...
      },
    ...
}
...

Revision history for this message
Malleshi C N (malleshicn) said :
#4

Hi Zane,

Thanks for the update. Now I am able to launch the instance ..but I am unable to launch wordpress.

when I checked it i found that mysql, httpd,mysql-server & wordpress was not installed. I am installing it manually now.

but my question is why these packages not installed via script mentioned in template through yum )...?

below is the error message:
 /bin/systemctl status httpd.service

Loaded: error (Reason:No such file or directory_

Active: Inactive (dead)

Thanks again for your wonderful assistance and help to fixing the problem ...

Revision history for this message
Zane Bitter (zaneb) said :
#5

Do you have the heat-cfn-tools package installed in the image? The first line in the UserData script, "/opt/aws/bin/cfn-init\n", is the one that processes the "AWS::CloudFormation::Init" section of the Metadata and installs the listed packages.

If you don't have it installed, you'll either need to build an image that includes it or "yum install" it before calling it in the UserData script.

Revision history for this message
Malleshi C N (malleshicn) said :
#6

Hi Zane,

I found that in my fedora (F17) image heat-cfn-tools package is not there.

I tried to create stack with a floating IP associated.

https://github.com/abckey/heattemplates/raw/master/WordPress_Single_Instance_With_EIP.template

but its showed that

2014-02-25 08:28:54.812 905 TRACE heat.engine.resource NotFound: FloatingIpPoolNotFound: Floating ip pool not found. (HTTP 404) (Request-ID: req-27fbeae1-2e93-4cd9-a093-18365e394710)
2014-02-25 08:28:54.812 905 TRACE heat.engine.resource
2014-02-25 08:28:54.864 905 WARNING heat.engine.service [-] Stack create failed, status FAILED

do I need to add Floating IP pool to my template?

Revision history for this message
Zane Bitter (zaneb) said :
#7

Since you are using Neutron instead of Nova-network, I think you need to set the 'Domain': 'vpc' property on the IPAddress and IPAssoc resources, and change 'EIP': {'Ref': 'IPAddress'} to 'AllocationId': {'Fn::GetAttr': ['IPAddress', 'AllocationId']} in the IPAssoc resource.

Revision history for this message
Malleshi C N (malleshicn) said :
#8

Hi Zane Thanks for you continuous assistance.

Coming to floating Ip problem.. I am unable to get as i am making mistake in template.

I will look into that. back to my prebious question , heat-cfn-tool is not available

[root@mystack-wikidatabase-d6vxmo7tgtqr ~]# yum install heat-cfn-tool
Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.cse.iitk.ac.in
 * updates: mirror.cse.iitk.ac.in
No package heat-cfn-tool available.
Error: Nothing to do
[root@mystack-wikidatabase-d6vxmo7tgtqr ~]# yum install heat-cfn-tools
Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.cse.iitk.ac.in
 * updates: mirror.cse.iitk.ac.in
No package heat-cfn-tools available.
Error: Nothing to do
[root@mystack-wikidatabase-d6vxmo7tgtqr ~]# yum install heat-cfntools
Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.cse.iitk.ac.in
 * updates: mirror.cse.iitk.ac.in
No package heat-cfntools available.
Error: Nothing to do
===============
[root@mystack-wikidatabase-d6vxmo7tgtqr tmp]# ls
heat-cfntools-1.2.3-1.el6.noarch.rpm
[root@mystack-wikidatabase-d6vxmo7tgtqr tmp]# rpm -ivh heat-cfntools-1.2.3-1.el6.noarch.rpm
warning: heat-cfntools-1.2.3-1.el6.noarch.rpm: Header V4 RSA/SHA1 Signature, key ID 2bc7c801: NOKEY
error: Failed dependencies:
        python(abi) = 2.6 is needed by heat-cfntools-1.2.3-1.el6.noarch
[root@mystack-wikidatabase-d6vxmo7tgtqr tmp]# yum install python-abi
Loaded plugins: fastestmirror, langpacks, presto, refresh-packagekit
Loading mirror speeds from cached hostfile
 * fedora: mirror.cse.iitk.ac.in
 * updates: mirror.cse.iitk.ac.in
Package python-2.7.3-7.2.fc17.x86_64 already installed and latest version
Nothing to do
==

let me know how can I go further ...

Revision history for this message
Zane Bitter (zaneb) said :
#9

For Fedora 17 you probably need to install an additional yum repository: http://fedoraproject.org/wiki/Getting_started_with_OpenStack_on_Fedora_17#Fedora_OpenStack_preview_repository

However, I highly recommend you update to Fedora 20. Fedora 17 is waaaaay old, no longer supported, and even I have upgraded ;)

The heat-cfntools package is in the standard Fedora repos for at least Fedora 19 and later (and IIRC for Fedora 18 as well, but don't quote me on that).

Revision history for this message
Malleshi C N (malleshicn) said :
#10

Hello Zane , Thanks for the update .

I am trying with fedora 19 image now..

Revision history for this message
Malleshi C N (malleshicn) said :
#11

Hi Zane,

I am able to launch a stack wuth fedora 19, but even though ot has heat-cfn-tool package , why by default its not installing package

  "Resources" : {
    "WikiDatabase": {
      "Type": "AWS::EC2::Instance",
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
            "packages" : {
              "yum -y install" : {
                "mysql" : [],
                "mysql-server" : [],
                "httpd" : [],
                "wordpress" : []
              }
            },
            "services" : {
              "systemd" : {
                "mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
                "httpd" : { "enabled" : "true", "ensureRunning" : "true" }
above if I specify only 'Yum ' under package , my provision log will b empty , if I specify 'yum install' below is the out put:

[root@mystack-wikidatabase-kbdqvlg7rtd2 log]# more heat-provision.log
Provision began: 2014-03-05 23:20:53.587316

/var/lib/heat-cfntools/cfn-userdata

#!/bin/bash -v
/opt/aws/bin/cfn-init
WARNING [2014-03-05 23:20:53,777] Unable to retrieve remote metadata : No credentials!
WARNING [2014-03-05 23:20:53,778] Unable to open local metadata : /tmp/last_metadata
INFO [2014-03-05 23:20:53,778] Opened local metadata /var/lib/heat-cfntools/cfn-init-data
WARNING [2014-03-05 23:20:53,780] Skipping invalid package type: yum install
INFO [2014-03-05 23:20:53,781] Enabling service httpd
DEBUG [2014-03-05 23:20:53,781] Running command: /bin/systemctl enable httpd.service
DEBUG [2014-03-05 23:20:53,879] Return code of 1 after executing: '['su', 'root', '-c', u'/bin/systemctl enable httpd.service'
]'
DEBUG [2014-03-05 23:20:53,880] Running command: /bin/systemctl status httpd.service
DEBUG [2014-03-05 23:20:53,916] Return code of 3 after executing: '['su', 'root', '-c', u'/bin/systemctl status httpd.service'
]'
INFO [2014-03-05 23:20:53,916] Starting service httpd
DEBUG [2014-03-05 23:20:53,917] Running command: /bin/systemctl start httpd.service
DEBUG [2014-03-05 23:20:53,945] Return code of 6 after executing: '['su', 'root', '-c', u'/bin/systemctl start httpd.service']
'
INFO [2014-03-05 23:20:53,946] Enabling service mysqld
DEBUG [2014-03-05 23:20:53,946] Running command: /bin/systemctl enable mysqld.service
DEBUG [2014-03-05 23:20:53,973] Return code of 1 after executing: '['su', 'root', '-c', u'/bin/systemctl enable mysqld.service
']'
DEBUG [2014-03-05 23:20:53,973] Running command: /bin/systemctl status mysqld.service
DEBUG [2014-03-05 23:20:54,002] Return code of 3 after executing: '['su', 'root', '-c', u'/bin/systemctl status mysqld.service
']'
INFO [2014-03-05 23:20:54,002] Starting service mysqld
DEBUG [2014-03-05 23:20:54,002] Running command: /bin/systemctl start mysqld.service
DEBUG [2014-03-05 23:20:54,033] Return code of 6 after executing: '['su', 'root', '-c', u'/bin/systemctl start mysqld.service'
]'
# Setup MySQL root password and create a user
mysqladmin -u root password 'admin'
/var/lib/heat-cfntools/cfn-userdata: line 4: mysqladmin: command not found
cat << EOF | mysql -u root --password='admin'
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO "USERNAME"@"localhost"
IDENTIFIED BY "PASSWORD";
FLUSH PRIVILEGES;
EXIT
EOF
/var/lib/heat-cfntools/cfn-userdata: line 5: mysql: command not found
cat: write error: Broken pipe
sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
sed: can't read /etc/httpd/conf.d/wordpress.conf: No such file or directory
sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf
sed: can't read /etc/httpd/conf.d/wordpress.conf: No such file or directory
sed --in-place --e s/database_name_here/wordpress/ --e s/username_here/USERNAME/ --e s/password_here/PASSWORD/ /usr/share/word
press/wp-config.php
sed: can't read /usr/share/wordpress/wp-config.php: No such file or directory
systemctl restart httpd.service

of I specify ' yum -y install " below is error message followed by rest of the message.
WARNING [2014-03-06 00:57:13,163] Skipping invalid package type: yum -y install

where I am failing to launch wordpress ..? please assist me

Revision history for this message
Zane Bitter (zaneb) said :
#12

I suspect because you've changed the package manager from "yum", which is a known package manager to "yum -y install", which is not. The valid values for "pacakges" keys are "dpkg", "rpm", "apt" and "yum". It's not a command line; heat-cfn-init takes care of executing the correct command.

Revision history for this message
Malleshi C N (malleshicn) said :
#13

Hello Zane ,

This is the error from heat-provision.log, I am able to launch stack , but packages not getting installed at run time

[root@mystack-wikidatabase-3zmn23umyrg7 log]# more heat-provision.log
Provision began: 2014-03-07 04:23:46.738330

/var/lib/heat-cfntools/cfn-userdata

#!/bin/bash -v
/opt/aws/bin/cfn-init
WARNING [2014-03-07 04:23:47,311] Unable to retrieve remote metadata : No credentials!
WARNING [2014-03-07 04:23:47,311] Unable to open local metadata : /tmp/last_metadata
WARNING [2014-03-07 04:23:47,312] Unable to open local metadata : /var/lib/heat-cfntools/cfn-init-data
ERROR [2014-03-07 04:23:47,312] Unable to read any valid metadata!
ERROR [2014-03-07 04:23:47,312] Error processing metadata
Traceback (most recent call last):
  File "/opt/aws/bin/cfn-init", line 71, in <module>
    metadata.cfn_init()
  File "/usr/lib/python2.7/site-packages/heat_cfntools/cfntools/cfn_helper.py", line 1187, in cfn_init
    raise Exception("invalid metadata")
Exception: invalid metadata
# Setup MySQL root password and create a user
mysqladmin -u root password 'admin'
/var/lib/heat-cfntools/cfn-userdata: line 4: mysqladmin: command not found
cat << EOF | mysql -u root --password='admin'
CREATE DATABASE wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO "USERNAME"@"localhost"
IDENTIFIED BY "PASSWORD";
FLUSH PRIVILEGES;
EXIT
EOF
/var/lib/heat-cfntools/cfn-userdata: line 5: mysql: command not found
cat: write error: Broken pipe
sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf
sed: can't read /etc/httpd/conf.d/wordpress.conf: No such file or directory
sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf
sed: can't read /etc/httpd/conf.d/wordpress.conf: No such file or directory
sed --in-place --e s/database_name_here/wordpress/ --e s/username_here/USERNAME/ --e s/password_here/PASSWORD/ /usr/share/word
press/wp-config.php
sed: can't read /usr/share/wordpress/wp-config.php: No such file or directory
systemctl restart httpd.service
Failed to issue method call: Unit httpd.service failed to load: No such file or directory. See system logs and 'systemctl stat
us httpd.service' for details.
firewall-cmd --add-service=http
/var/lib/heat-cfntools/cfn-userdata: line 16: firewall-cmd: command not found
firewall-cmd --permanent --add-service=http
/var/lib/heat-cfntools/cfn-userdata: line 17: firewall-cmd: command not found

Provision done: 2014-03-07 04:23:47.364607

Provision failed with exit code 127
=============================

"Resources" : {
    "WikiDatabase": {
      "Type": "AWS::EC2::Instance",
      "Properties": {
      "SubnetId": {"Ref": "SubnetId"},
      "Metadata" : {
        "AWS::CloudFormation::Init" : {
          "config" : {
            "packages" : {
              "yum" : {
                "mysql" : [],
                "mysql-server" : [],
                "httpd" : [],
                "wordpress" : []
              }
            }
            },
            "services" : {
              "systemd" : {
                "mysqld" : { "enabled" : "true", "ensureRunning" : "true" },
                "httpd" : { "enabled" : "true", "ensureRunning" : "true" }
              }
            }
          }
=========================

Revision history for this message
Malleshi C N (malleshicn) said :
#14

solved

Revision history for this message
Malleshi C N (malleshicn) said :
#15

Thanks Zane Bitter, that solved my question.