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
pull/23086/head
Jon "The Nice Guy" Spriggs 8 years ago committed by Monty Taylor
parent c8364d64d6
commit 8e0c11ebc4

@ -373,6 +373,46 @@ EXAMPLES = '''
volumes:
- photos
- 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:

Loading…
Cancel
Save