Я хочу запустить несколько команд после загрузки сервера из шаблона HOT. Нет никаких ошибок; команды внутри 'runcmd' просто не работают.
Server02:
type: OS::Nova::Server
properties:
name: { get_param: [SV_HOSTNAMES, 1] }
flavor: { get_param: FLAVOR_N }
image: { get_param: IMAGE_N }
networks:
- port: { get_resource: Server02_PRI_NET_ID_port }
- port: { get_resource: Server02_SEC_NET_ID_port }
config_drive: true
user_data_format: RAW
user_data:
str_replace:
template: |
runcmd: |
#!/bin/sh
echo $ETH0_IP $NODENAME.vil.in >> /etc/hosts
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
echo -e "BOOTPROTO=static\nDEVICE=eth0\nIPADDR=$ETH0_IP\nPREFIX=24\nONBOOT=yes\nMTU=9000\nTYPE=Ethernet\nUSERCTL=no\nNMCONTROLLED=no" > /etc/sysconfig/network-scripts/ifcfg-eth0
rm -f /etc/sysconfig/network-scripts/ifcfg-eth1
echo -e "BOOTPROTO=static\nDEVICE=eth1\nIPADDR=$ETH1_IP\nPREFIX=24\nONBOOT=yes\nMTU=9000\nTYPE=Ethernet\nUSERCTL=no\nNMCONTROLLED=no" > /etc/sysconfig/network-scripts/ifcfg-eth1
sync;sync;shutdown -r +1
params:
$NODENAME: { get_param: [SV_HOSTNAMES, 1] }
$ETH0_IP: { get_attr: [Server02_PRI_NET_ID_port, fixed_ips, 0, ip_address] }
$NETGW0: { get_attr: [Server02_PRI_NET_ID_port, subnets, 0, gateway_ip] }
$NETCIDR0: { get_attr: [Server02_PRI_NET_ID_port, subnets, 0, cidr] }
$ETH1_IP: { get_attr: [Server02_SEC_NET_ID_port, fixed_ips, 0, ip_address] }
$NETGW1: { get_attr: [Server02_SEC_NET_ID_port, subnets, 0, gateway_ip] }
$NETCIDR1: { get_attr: [Server02_SEC_NET_ID_port, subnets, 0, cidr] }
$VOL0: {get_resource: Server02_VDB_VOL }
Строки ниже работают должным образом, но не могут передавать параметры в cloud_config
#*************************************************#
#***********Instance Definition*****************#
#*************************************************#
vServer1:
type: OS::Nova::Server
properties:
name:
str_replace:
template: { get_param: sv_hostname }
params:
HOSTNAME: { get_param: sv_hostname }
flavor: F_TestSmall
image: rhel7-image
networks:
- port: { get_resource: port_instance1a }
- port: { get_resource: port_instance1b }
config_drive: true
user_data_format: SOFTWARE_CONFIG
user_data: {get_resource: root_config}
#*************************************************#
#***********Script Definition*****************#
#*************************************************#
root_config:
type: OS::Heat::CloudConfig
properties:
cloud_config:
ssh_pwauth: true
disable_root: false
chpasswd: { expire: False }
write_files:
- path: /tmp/test_script.sh
permissions: '0777'
content: |
#!/bin/bash
rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
echo -e "BOOTPROTO=static\nDEVICE=eth0\nIPADDR=12.16.33.5\nNETMASK=255.255.255.0\nONBOOT=yes\nMTU=9000\nTYPE=Ethernet\nUSERCTL=no\nNMCONTROLLED=no" > /etc/sysconfig/network-scripts/ifcfg-eth0
rm -f /etc/sysconfig/network-scripts/ifcfg-eth1
echo -e "BOOTPROTO=static\nDEVICE=eth1\nIPADDR=12.16.34.5\nNETMASK=255.255.255.0\nONBOOT=yes\nMTU=9000\nTYPE=Ethernet\nUSERCTL=no\nNMCONTROLLED=no" > /etc/sysconfig/network-scripts/ifcfg-eth1
service network restart
systemctl disable cloud-init.service
runcmd:
- sh /tmp/test_script.sh
Я также попытался удалить 'runcmd 'и выполнение команд под user_data, но безуспешно.