mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add examples in os_server module showing userdata (#22997)
* Add examples in os_server module showing userdata Added an example using Bash and also using Cloud-init. Also, showing using {% raw %} and {% endraw %} to provide a pointer to those hitting similar issues to the ones I had. * Removed erronious whitespace
This commit is contained in:
parent
c8364d64d6
commit
8e0c11ebc4
1 changed files with 40 additions and 0 deletions
|
@ -373,6 +373,46 @@ EXAMPLES = '''
|
||||||
volumes:
|
volumes:
|
||||||
- photos
|
- photos
|
||||||
- music
|
- music
|
||||||
|
|
||||||
|
# Creates a new instance with provisioning userdata using Cloud-Init
|
||||||
|
- name: launch a compute instance
|
||||||
|
hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- name: launch an instance
|
||||||
|
os_server:
|
||||||
|
name: vm1
|
||||||
|
state: present
|
||||||
|
image: "Ubuntu Server 14.04"
|
||||||
|
flavor: "P-1"
|
||||||
|
network: "Production"
|
||||||
|
userdata: |
|
||||||
|
#cloud-config
|
||||||
|
chpasswd:
|
||||||
|
list: |
|
||||||
|
ubuntu:{{ default_password }}
|
||||||
|
expire: False
|
||||||
|
packages:
|
||||||
|
- ansible
|
||||||
|
package_upgrade: true
|
||||||
|
|
||||||
|
# Creates a new instance with provisioning userdata using Bash Scripts
|
||||||
|
- name: launch a compute instance
|
||||||
|
hosts: localhost
|
||||||
|
tasks:
|
||||||
|
- name: launch an instance
|
||||||
|
os_server:
|
||||||
|
name: vm1
|
||||||
|
state: present
|
||||||
|
image: "Ubuntu Server 14.04"
|
||||||
|
flavor: "P-1"
|
||||||
|
network: "Production"
|
||||||
|
userdata: |
|
||||||
|
{%- raw -%}#!/bin/bash
|
||||||
|
echo " up ip route add 10.0.0.0/8 via {% endraw -%}{{ intra_router }}{%- raw -%}" >> /etc/network/interfaces.d/eth0.conf
|
||||||
|
echo " down ip route del 10.0.0.0/8" >> /etc/network/interfaces.d/eth0.conf
|
||||||
|
ifdown eth0 && ifup eth0
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Reference in a new issue