Mailing List Archive

about cloud-init question
Hi All,

I have a problem about cloud-init.
I want to both transfer files and execute script. So I give below script to user-data when I create instance.
#cloud-config
write_files:
- encoding: b64
content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
owner: root:root
path: /root/hhb.gz
permissions: '0644'

#!/bin/bash
mkdir -p /home/ubuntu/config

but, I can't get /root/hhb.gz and /home/Ubuntu/config.
If I separate transfer files and execute script. It is ok.
Any idea?

Below is my debug info

ubuntu@onap-hhb7:~$ sudo cloud-init --version

sudo: unable to resolve host onap-hhb7

cloud-init 0.7.5



security-groupsubuntu@onap-hhb7:~$ curl http://169.254.169.254/2009-04-04/user-data

#cloud-config

write_files:

- encoding: b64

content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==

owner: root:root

path: /root/hhb.gz

permissions: '0644'



#!/bin/bash

mkdir -p /home/ubuntu/config



ubuntu@onap-hhb7:~$ sudo ls /root/ -a

. .. .bashrc .profile .ssh



ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls

boot-finished datasource obj.pkl sem user-data.txt.i vendor-data.txt.i

cloud-config.txt handlers scripts user-data.txt vendor-data.txt

ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt

sudo: unable to resolve host onap-hhb7

#cloud-config

write_files:

- encoding: b64

content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==

owner: root:root

path: /root/hhb.gz

permissions: '0644'



#!/bin/bash

mkdir -p /home/ubuntu/config



-------------------------------------------------------------------------------------------------------------------------------
Huang.haibin
11628530
86+18106533356
Re: about cloud-init question [ In reply to ]
Hi,

I dont think its possible to switch the interpreter during the run.

I would suggest to take a look into your cloud-init.log maybe its telling you why it is not doing what you want.

Fabian Zimmermann


Am 23. April 2018 03:08:15 MESZ schrieb "Huang, Haibin" <haibin.huang@intel.com>:
>Hi All,
>
>I have a problem about cloud-init.
>I want to both transfer files and execute script. So I give below
>script to user-data when I create instance.
>#cloud-config
>write_files:
>- encoding: b64
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> owner: root:root
> path: /root/hhb.gz
> permissions: '0644'
>
>#!/bin/bash
>mkdir -p /home/ubuntu/config
>
>but, I can't get /root/hhb.gz and /home/Ubuntu/config.
>If I separate transfer files and execute script. It is ok.
>Any idea?
>
>Below is my debug info
>
>ubuntu@onap-hhb7:~$ sudo cloud-init --version
>
>sudo: unable to resolve host onap-hhb7
>
>cloud-init 0.7.5
>
>
>
>security-groupsubuntu@onap-hhb7:~$ curl
>http://169.254.169.254/2009-04-04/user-data
>
>#cloud-config
>
>write_files:
>
>- encoding: b64
>
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>
> owner: root:root
>
> path: /root/hhb.gz
>
> permissions: '0644'
>
>
>
>#!/bin/bash
>
>mkdir -p /home/ubuntu/config
>
>
>
>ubuntu@onap-hhb7:~$ sudo ls /root/ -a
>
>. .. .bashrc .profile .ssh
>
>
>
>ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
>
>boot-finished datasource obj.pkl sem user-data.txt.i
>vendor-data.txt.i
>
>cloud-config.txt handlers scripts user-data.txt vendor-data.txt
>
>ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
>
>sudo: unable to resolve host onap-hhb7
>
>#cloud-config
>
>write_files:
>
>- encoding: b64
>
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>
> owner: root:root
>
> path: /root/hhb.gz
>
> permissions: '0644'
>
>
>
>#!/bin/bash
>
>mkdir -p /home/ubuntu/config
>
>
>
>-------------------------------------------------------------------------------------------------------------------------------
>Huang.haibin
>11628530
>86+18106533356
Re: about cloud-init question [ In reply to ]
Hi Fabian,

I have export cloud-init.log as attachment.
I can’t find the reason. Can you help me to see it.

Thank you!

From: Fabian Zimmermann [mailto:dev.faz@gmail.com]
Sent: Monday, April 23, 2018 12:14 PM
To: Huang, Haibin <haibin.huang@intel.com>; openstack@lists.openstack.org
Subject: Re: [Openstack] about cloud-init question

Hi,

I dont think its possible to switch the interpreter during the run.

I would suggest to take a look into your cloud-init.log maybe its telling you why it is not doing what you want.

Fabian Zimmermann

Am 23. April 2018 03:08:15 MESZ schrieb "Huang, Haibin" <haibin.huang@intel.com<mailto:haibin.huang@intel.com>>:
Hi All,

I have a problem about cloud-init.
I want to both transfer files and execute script. So I give below script to user-data when I create instance.
#cloud-config
write_files:
- encoding: b64
content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
owner: root:root
path: /root/hhb.gz
permissions: '0644'

#!/bin/bash
mkdir -p /home/ubuntu/config

but, I can’t get /root/hhb.gz and /home/Ubuntu/config.
If I separate transfer files and execute script. It is ok.
Any idea?

Below is my debug info

ubuntu@onap-hhb7:~$ sudo cloud-init --version

sudo: unable to resolve host onap-hhb7

cloud-init 0.7.5



security-groupsubuntu@onap-hhb7:~$ curl http://169.254.169.254/2009-04-04/user-data

#cloud-config

write_files:

- encoding: b64

content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==

owner: root:root

path: /root/hhb.gz

permissions: '0644'



#!/bin/bash

mkdir -p /home/ubuntu/config



ubuntu@onap-hhb7:~$ sudo ls /root/ -a

. .. .bashrc .profile .ssh



ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls

boot-finished datasource obj.pkl sem user-data.txt.i vendor-data.txt.i

cloud-config.txt handlers scripts user-data.txt vendor-data.txt

ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt

sudo: unable to resolve host onap-hhb7

#cloud-config

write_files:

- encoding: b64

content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==

owner: root:root

path: /root/hhb.gz

permissions: '0644'



#!/bin/bash

mkdir -p /home/ubuntu/config



-------------------------------------------------------------------------------------------------------------------------------
Huang.haibin
11628530
86+18106533356
Re: about cloud-init question [ In reply to ]
Hi,

we use this piece of script to pass salt data to instances and execute
the respective commands to start the salt-minion:

---cut here---
#cloud-config
write_files:
# Minion Konfiguration
- content: |
master: <IP>
id: <HOSTNAME>
[...]
owner: root:root
path: /etc/salt/minion.d/init.conf
permissions: '0644'

# Minion Private-Key
- content: |
-----BEGIN RSA PRIVATE KEY-----
[...]
-----END RSA PRIVATE KEY-----
owner: root:root
path: /etc/salt/pki/minion/minion.pem
permissions: '0400'

[...]

# Enabled und Startet den Minion
runcmd:
- rm -f /etc/machine-id
- systemd-machine-id-setup
- [ systemctl, enable, salt-minion.service ]
- [ systemctl, start, --no-block, salt-minion.service ]
- [ systemctl, daemon-reload ]
---cut here---

This both writes the desired files and also executes required
commands. We use this on openSUSE machines, I'm not sure if this
differs in your environment, but worth a shot, I guess.

Regards,
Eugen


Zitat von "Huang, Haibin" <haibin.huang@intel.com>:

> Hi All,
>
> I have a problem about cloud-init.
> I want to both transfer files and execute script. So I give below
> script to user-data when I create instance.
> #cloud-config
> write_files:
> - encoding: b64
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> owner: root:root
> path: /root/hhb.gz
> permissions: '0644'
>
> #!/bin/bash
> mkdir -p /home/ubuntu/config
>
> but, I can't get /root/hhb.gz and /home/Ubuntu/config.
> If I separate transfer files and execute script. It is ok.
> Any idea?
>
> Below is my debug info
>
> ubuntu@onap-hhb7:~$ sudo cloud-init --version
>
> sudo: unable to resolve host onap-hhb7
>
> cloud-init 0.7.5
>
>
>
> security-groupsubuntu@onap-hhb7:~$ curl
> http://169.254.169.254/2009-04-04/user-data
>
> #cloud-config
>
> write_files:
>
> - encoding: b64
>
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>
> owner: root:root
>
> path: /root/hhb.gz
>
> permissions: '0644'
>
>
>
> #!/bin/bash
>
> mkdir -p /home/ubuntu/config
>
>
>
> ubuntu@onap-hhb7:~$ sudo ls /root/ -a
>
> . .. .bashrc .profile .ssh
>
>
>
> ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
>
> boot-finished datasource obj.pkl sem
> user-data.txt.i vendor-data.txt.i
>
> cloud-config.txt handlers scripts user-data.txt vendor-data.txt
>
> ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
>
> sudo: unable to resolve host onap-hhb7
>
> #cloud-config
>
> write_files:
>
> - encoding: b64
>
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>
> owner: root:root
>
> path: /root/hhb.gz
>
> permissions: '0644'
>
>
>
> #!/bin/bash
>
> mkdir -p /home/ubuntu/config
>
>
>
> -------------------------------------------------------------------------------------------------------------------------------
> Huang.haibin
> 11628530
> 86+18106533356




_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Re: about cloud-init question [ In reply to ]
I suspect my cloud-init version is too lower. Can you share me your cloud-init version?
Thank you!

> -----Original Message-----
> From: Eugen Block [mailto:eblock@nde.ag]
> Sent: Monday, April 23, 2018 2:58 PM
> To: openstack@lists.openstack.org
> Subject: Re: [Openstack] about cloud-init question
>
> Hi,
>
> we use this piece of script to pass salt data to instances and execute the
> respective commands to start the salt-minion:
>
> ---cut here---
> #cloud-config
> write_files:
> # Minion Konfiguration
> - content: |
> master: <IP>
> id: <HOSTNAME>
> [...]
> owner: root:root
> path: /etc/salt/minion.d/init.conf
> permissions: '0644'
>
> # Minion Private-Key
> - content: |
> -----BEGIN RSA PRIVATE KEY-----
> [...]
> -----END RSA PRIVATE KEY-----
> owner: root:root
> path: /etc/salt/pki/minion/minion.pem
> permissions: '0400'
>
> [...]
>
> # Enabled und Startet den Minion
> runcmd:
> - rm -f /etc/machine-id
> - systemd-machine-id-setup
> - [ systemctl, enable, salt-minion.service ]
> - [ systemctl, start, --no-block, salt-minion.service ]
> - [ systemctl, daemon-reload ]
> ---cut here---
>
> This both writes the desired files and also executes required commands. We use
> this on openSUSE machines, I'm not sure if this differs in your environment, but
> worth a shot, I guess.
>
> Regards,
> Eugen
>
>
> Zitat von "Huang, Haibin" <haibin.huang@intel.com>:
>
> > Hi All,
> >
> > I have a problem about cloud-init.
> > I want to both transfer files and execute script. So I give below
> > script to user-data when I create instance.
> > #cloud-config
> > write_files:
> > - encoding: b64
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> > owner: root:root
> > path: /root/hhb.gz
> > permissions: '0644'
> >
> > #!/bin/bash
> > mkdir -p /home/ubuntu/config
> >
> > but, I can't get /root/hhb.gz and /home/Ubuntu/config.
> > If I separate transfer files and execute script. It is ok.
> > Any idea?
> >
> > Below is my debug info
> >
> > ubuntu@onap-hhb7:~$ sudo cloud-init --version
> >
> > sudo: unable to resolve host onap-hhb7
> >
> > cloud-init 0.7.5
> >
> >
> >
> > security-groupsubuntu@onap-hhb7:~$ curl
> > http://169.254.169.254/2009-04-04/user-data
> >
> > #cloud-config
> >
> > write_files:
> >
> > - encoding: b64
> >
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> >
> > owner: root:root
> >
> > path: /root/hhb.gz
> >
> > permissions: '0644'
> >
> >
> >
> > #!/bin/bash
> >
> > mkdir -p /home/ubuntu/config
> >
> >
> >
> > ubuntu@onap-hhb7:~$ sudo ls /root/ -a
> >
> > . .. .bashrc .profile .ssh
> >
> >
> >
> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
> >
> > boot-finished datasource obj.pkl sem
> > user-data.txt.i vendor-data.txt.i
> >
> > cloud-config.txt handlers scripts user-data.txt vendor-data.txt
> >
> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
> >
> > sudo: unable to resolve host onap-hhb7
> >
> > #cloud-config
> >
> > write_files:
> >
> > - encoding: b64
> >
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> >
> > owner: root:root
> >
> > path: /root/hhb.gz
> >
> > permissions: '0644'
> >
> >
> >
> > #!/bin/bash
> >
> > mkdir -p /home/ubuntu/config
> >
> >
> >
> > ----------------------------------------------------------------------
> > ---------------------------------------------------------
> > Huang.haibin
> > 11628530
> > 86+18106533356
>
>
>
>
> _______________________________________________
> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to : openstack@lists.openstack.org
> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Re: about cloud-init question [ In reply to ]
Currently, we use

host:~ # cloud-init --version
cloud-init 0.7.8


Zitat von "Huang, Haibin" <haibin.huang@intel.com>:

> I suspect my cloud-init version is too lower. Can you share me your
> cloud-init version?
> Thank you!
>
>> -----Original Message-----
>> From: Eugen Block [mailto:eblock@nde.ag]
>> Sent: Monday, April 23, 2018 2:58 PM
>> To: openstack@lists.openstack.org
>> Subject: Re: [Openstack] about cloud-init question
>>
>> Hi,
>>
>> we use this piece of script to pass salt data to instances and execute the
>> respective commands to start the salt-minion:
>>
>> ---cut here---
>> #cloud-config
>> write_files:
>> # Minion Konfiguration
>> - content: |
>> master: <IP>
>> id: <HOSTNAME>
>> [...]
>> owner: root:root
>> path: /etc/salt/minion.d/init.conf
>> permissions: '0644'
>>
>> # Minion Private-Key
>> - content: |
>> -----BEGIN RSA PRIVATE KEY-----
>> [...]
>> -----END RSA PRIVATE KEY-----
>> owner: root:root
>> path: /etc/salt/pki/minion/minion.pem
>> permissions: '0400'
>>
>> [...]
>>
>> # Enabled und Startet den Minion
>> runcmd:
>> - rm -f /etc/machine-id
>> - systemd-machine-id-setup
>> - [ systemctl, enable, salt-minion.service ]
>> - [ systemctl, start, --no-block, salt-minion.service ]
>> - [ systemctl, daemon-reload ]
>> ---cut here---
>>
>> This both writes the desired files and also executes required
>> commands. We use
>> this on openSUSE machines, I'm not sure if this differs in your
>> environment, but
>> worth a shot, I guess.
>>
>> Regards,
>> Eugen
>>
>>
>> Zitat von "Huang, Haibin" <haibin.huang@intel.com>:
>>
>> > Hi All,
>> >
>> > I have a problem about cloud-init.
>> > I want to both transfer files and execute script. So I give below
>> > script to user-data when I create instance.
>> > #cloud-config
>> > write_files:
>> > - encoding: b64
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> > owner: root:root
>> > path: /root/hhb.gz
>> > permissions: '0644'
>> >
>> > #!/bin/bash
>> > mkdir -p /home/ubuntu/config
>> >
>> > but, I can't get /root/hhb.gz and /home/Ubuntu/config.
>> > If I separate transfer files and execute script. It is ok.
>> > Any idea?
>> >
>> > Below is my debug info
>> >
>> > ubuntu@onap-hhb7:~$ sudo cloud-init --version
>> >
>> > sudo: unable to resolve host onap-hhb7
>> >
>> > cloud-init 0.7.5
>> >
>> >
>> >
>> > security-groupsubuntu@onap-hhb7:~$ curl
>> > http://169.254.169.254/2009-04-04/user-data
>> >
>> > #cloud-config
>> >
>> > write_files:
>> >
>> > - encoding: b64
>> >
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> >
>> > owner: root:root
>> >
>> > path: /root/hhb.gz
>> >
>> > permissions: '0644'
>> >
>> >
>> >
>> > #!/bin/bash
>> >
>> > mkdir -p /home/ubuntu/config
>> >
>> >
>> >
>> > ubuntu@onap-hhb7:~$ sudo ls /root/ -a
>> >
>> > . .. .bashrc .profile .ssh
>> >
>> >
>> >
>> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
>> >
>> > boot-finished datasource obj.pkl sem
>> > user-data.txt.i vendor-data.txt.i
>> >
>> > cloud-config.txt handlers scripts user-data.txt vendor-data.txt
>> >
>> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
>> >
>> > sudo: unable to resolve host onap-hhb7
>> >
>> > #cloud-config
>> >
>> > write_files:
>> >
>> > - encoding: b64
>> >
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> >
>> > owner: root:root
>> >
>> > path: /root/hhb.gz
>> >
>> > permissions: '0644'
>> >
>> >
>> >
>> > #!/bin/bash
>> >
>> > mkdir -p /home/ubuntu/config
>> >
>> >
>> >
>> > ----------------------------------------------------------------------
>> > ---------------------------------------------------------
>> > Huang.haibin
>> > 11628530
>> > 86+18106533356
>>
>>
>>
>>
>> _______________________________________________
>> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>> Post to : openstack@lists.openstack.org
>> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack




_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Re: about cloud-init question [ In reply to ]
Hi
I use below config can create both /root/hhb.gz and /home/Ubuntu/config.
Thank you very much!

#cloud-config
write_files:
- encoding: b64
content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
owner: root:root
path: /root/hhb.gz
permissions: '0644'

runcmd:
- mkdir -p /home/ubuntu/config
mkdir -p /home/ubuntu/config/hhb

> -----Original Message-----
> From: Eugen Block [mailto:eblock@nde.ag]
> Sent: Monday, April 23, 2018 2:58 PM
> To: openstack@lists.openstack.org
> Subject: Re: [Openstack] about cloud-init question
>
> Hi,
>
> we use this piece of script to pass salt data to instances and execute the
> respective commands to start the salt-minion:
>
> ---cut here---
> #cloud-config
> write_files:
> # Minion Konfiguration
> - content: |
> master: <IP>
> id: <HOSTNAME>
> [...]
> owner: root:root
> path: /etc/salt/minion.d/init.conf
> permissions: '0644'
>
> # Minion Private-Key
> - content: |
> -----BEGIN RSA PRIVATE KEY-----
> [...]
> -----END RSA PRIVATE KEY-----
> owner: root:root
> path: /etc/salt/pki/minion/minion.pem
> permissions: '0400'
>
> [...]
>
> # Enabled und Startet den Minion
> runcmd:
> - rm -f /etc/machine-id
> - systemd-machine-id-setup
> - [ systemctl, enable, salt-minion.service ]
> - [ systemctl, start, --no-block, salt-minion.service ]
> - [ systemctl, daemon-reload ]
> ---cut here---
>
> This both writes the desired files and also executes required commands. We use
> this on openSUSE machines, I'm not sure if this differs in your environment, but
> worth a shot, I guess.
>
> Regards,
> Eugen
>
>
> Zitat von "Huang, Haibin" <haibin.huang@intel.com>:
>
> > Hi All,
> >
> > I have a problem about cloud-init.
> > I want to both transfer files and execute script. So I give below
> > script to user-data when I create instance.
> > #cloud-config
> > write_files:
> > - encoding: b64
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> > owner: root:root
> > path: /root/hhb.gz
> > permissions: '0644'
> >
> > #!/bin/bash
> > mkdir -p /home/ubuntu/config
> >
> > but, I can't get /root/hhb.gz and /home/Ubuntu/config.
> > If I separate transfer files and execute script. It is ok.
> > Any idea?
> >
> > Below is my debug info
> >
> > ubuntu@onap-hhb7:~$ sudo cloud-init --version
> >
> > sudo: unable to resolve host onap-hhb7
> >
> > cloud-init 0.7.5
> >
> >
> >
> > security-groupsubuntu@onap-hhb7:~$ curl
> > http://169.254.169.254/2009-04-04/user-data
> >
> > #cloud-config
> >
> > write_files:
> >
> > - encoding: b64
> >
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> >
> > owner: root:root
> >
> > path: /root/hhb.gz
> >
> > permissions: '0644'
> >
> >
> >
> > #!/bin/bash
> >
> > mkdir -p /home/ubuntu/config
> >
> >
> >
> > ubuntu@onap-hhb7:~$ sudo ls /root/ -a
> >
> > . .. .bashrc .profile .ssh
> >
> >
> >
> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
> >
> > boot-finished datasource obj.pkl sem
> > user-data.txt.i vendor-data.txt.i
> >
> > cloud-config.txt handlers scripts user-data.txt vendor-data.txt
> >
> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
> >
> > sudo: unable to resolve host onap-hhb7
> >
> > #cloud-config
> >
> > write_files:
> >
> > - encoding: b64
> >
> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> >
> > owner: root:root
> >
> > path: /root/hhb.gz
> >
> > permissions: '0644'
> >
> >
> >
> > #!/bin/bash
> >
> > mkdir -p /home/ubuntu/config
> >
> >
> >
> > ----------------------------------------------------------------------
> > ---------------------------------------------------------
> > Huang.haibin
> > 11628530
> > 86+18106533356
>
>
>
>
> _______________________________________________
> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
> Post to : openstack@lists.openstack.org
> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Re: about cloud-init question [ In reply to ]
I'm glad I could help!


Zitat von "Huang, Haibin" <haibin.huang@intel.com>:

> Hi
> I use below config can create both /root/hhb.gz and /home/Ubuntu/config.
> Thank you very much!
>
> #cloud-config
> write_files:
> - encoding: b64
> content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
> owner: root:root
> path: /root/hhb.gz
> permissions: '0644'
>
> runcmd:
> - mkdir -p /home/ubuntu/config
> mkdir -p /home/ubuntu/config/hhb
>
>> -----Original Message-----
>> From: Eugen Block [mailto:eblock@nde.ag]
>> Sent: Monday, April 23, 2018 2:58 PM
>> To: openstack@lists.openstack.org
>> Subject: Re: [Openstack] about cloud-init question
>>
>> Hi,
>>
>> we use this piece of script to pass salt data to instances and execute the
>> respective commands to start the salt-minion:
>>
>> ---cut here---
>> #cloud-config
>> write_files:
>> # Minion Konfiguration
>> - content: |
>> master: <IP>
>> id: <HOSTNAME>
>> [...]
>> owner: root:root
>> path: /etc/salt/minion.d/init.conf
>> permissions: '0644'
>>
>> # Minion Private-Key
>> - content: |
>> -----BEGIN RSA PRIVATE KEY-----
>> [...]
>> -----END RSA PRIVATE KEY-----
>> owner: root:root
>> path: /etc/salt/pki/minion/minion.pem
>> permissions: '0400'
>>
>> [...]
>>
>> # Enabled und Startet den Minion
>> runcmd:
>> - rm -f /etc/machine-id
>> - systemd-machine-id-setup
>> - [ systemctl, enable, salt-minion.service ]
>> - [ systemctl, start, --no-block, salt-minion.service ]
>> - [ systemctl, daemon-reload ]
>> ---cut here---
>>
>> This both writes the desired files and also executes required
>> commands. We use
>> this on openSUSE machines, I'm not sure if this differs in your
>> environment, but
>> worth a shot, I guess.
>>
>> Regards,
>> Eugen
>>
>>
>> Zitat von "Huang, Haibin" <haibin.huang@intel.com>:
>>
>> > Hi All,
>> >
>> > I have a problem about cloud-init.
>> > I want to both transfer files and execute script. So I give below
>> > script to user-data when I create instance.
>> > #cloud-config
>> > write_files:
>> > - encoding: b64
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> > owner: root:root
>> > path: /root/hhb.gz
>> > permissions: '0644'
>> >
>> > #!/bin/bash
>> > mkdir -p /home/ubuntu/config
>> >
>> > but, I can't get /root/hhb.gz and /home/Ubuntu/config.
>> > If I separate transfer files and execute script. It is ok.
>> > Any idea?
>> >
>> > Below is my debug info
>> >
>> > ubuntu@onap-hhb7:~$ sudo cloud-init --version
>> >
>> > sudo: unable to resolve host onap-hhb7
>> >
>> > cloud-init 0.7.5
>> >
>> >
>> >
>> > security-groupsubuntu@onap-hhb7:~$ curl
>> > http://169.254.169.254/2009-04-04/user-data
>> >
>> > #cloud-config
>> >
>> > write_files:
>> >
>> > - encoding: b64
>> >
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> >
>> > owner: root:root
>> >
>> > path: /root/hhb.gz
>> >
>> > permissions: '0644'
>> >
>> >
>> >
>> > #!/bin/bash
>> >
>> > mkdir -p /home/ubuntu/config
>> >
>> >
>> >
>> > ubuntu@onap-hhb7:~$ sudo ls /root/ -a
>> >
>> > . .. .bashrc .profile .ssh
>> >
>> >
>> >
>> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ ls
>> >
>> > boot-finished datasource obj.pkl sem
>> > user-data.txt.i vendor-data.txt.i
>> >
>> > cloud-config.txt handlers scripts user-data.txt vendor-data.txt
>> >
>> > ubuntu@onap-hhb7:/var/lib/cloud/instance$ sudo cat user-data.txt
>> >
>> > sudo: unable to resolve host onap-hhb7
>> >
>> > #cloud-config
>> >
>> > write_files:
>> >
>> > - encoding: b64
>> >
>> > content: H4sICMxh2VoAA2hoYgCzKE5JK07hAgDCo1pOBwAAAA==
>> >
>> > owner: root:root
>> >
>> > path: /root/hhb.gz
>> >
>> > permissions: '0644'
>> >
>> >
>> >
>> > #!/bin/bash
>> >
>> > mkdir -p /home/ubuntu/config
>> >
>> >
>> >
>> > ----------------------------------------------------------------------
>> > ---------------------------------------------------------
>> > Huang.haibin
>> > 11628530
>> > 86+18106533356
>>
>>
>>
>>
>> _______________________________________________
>> Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
>> Post to : openstack@lists.openstack.org
>> Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack




_______________________________________________
Mailing list: http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack
Post to : openstack@lists.openstack.org
Unsubscribe : http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack