Created
March 31, 2019 10:33
-
-
Save rbo/ccd97157089f71da6a835d584bffe1cc to your computer and use it in GitHub Desktop.
os_server is not idempotent if I use port-id= - Multiple matches found for default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
--- | |
- hosts: localhost | |
gather_facts: false | |
connection: local | |
vars: | |
iaas_internal_network: admin | |
iaas_machine_size: m1.tiny | |
iaas_image: cirros-0.4.0 | |
auth: | |
auth_url: "{{ lookup('env','OS_AUTH_URL') }}" | |
project_name: "{{ lookup('env','OS_PROJECT_NAME') }}" | |
username: "{{ lookup('env','OS_USERNAME') }}" | |
password: "{{ lookup('env','OS_PASSWORD') }}" | |
tasks: | |
- name: Create port #1 | |
os_port: | |
state: present | |
auth: "{{ auth }}" | |
name: "port-for-instance-bc4493e3fb06f3553447b2b93496a30b" | |
network: "{{ iaas_internal_network }}" | |
no_security_groups: True | |
register: port_info | |
- name: Create instance #1 | |
ignore_errors: yes | |
os_server: | |
state: present | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" | |
image: "{{ iaas_image }}" | |
flavor: "{{ iaas_machine_size }}" | |
nics: | |
- "port-id={{ port_info.id }}" | |
- name: Create port #2 | |
os_port: | |
state: present | |
auth: "{{ auth }}" | |
name: "port-for-instance-bc4493e3fb06f3553447b2b93496a30b" | |
network: "{{ iaas_internal_network }}" | |
no_security_groups: True | |
register: port_info | |
- name: Create instance #2 | |
ignore_errors: yes | |
os_server: | |
state: present | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" | |
image: "{{ iaas_image }}" | |
flavor: "{{ iaas_machine_size }}" | |
nics: | |
- "port-id={{ port_info.id }}" | |
- name: Delete instance | |
os_server: | |
state: absent | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" | |
- name: Delete port | |
os_port: | |
state: absent | |
auth: '{{ auth }}' | |
name: "port-for-instance-bc4493e3fb06f3553447b2b93496a30b" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ansible-playbook | |
--- | |
- hosts: localhost | |
gather_facts: false | |
connection: local | |
vars: | |
iaas_internal_network: admin | |
iaas_machine_size: m1.tiny | |
iaas_image: cirros-0.4.0 | |
auth: | |
auth_url: "{{ lookup('env','OS_AUTH_URL') }}" | |
project_name: "{{ lookup('env','OS_PROJECT_NAME') }}" | |
username: "{{ lookup('env','OS_USERNAME') }}" | |
password: "{{ lookup('env','OS_PASSWORD') }}" | |
tasks: | |
- name: Create instance #1 | |
ignore_errors: yes | |
os_server: | |
state: present | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" | |
image: "{{ iaas_image }}" | |
flavor: "{{ iaas_machine_size }}" | |
network: "{{ iaas_internal_network }}" | |
- name: Create instance #2 | |
ignore_errors: yes | |
os_server: | |
state: present | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" | |
image: "{{ iaas_image }}" | |
flavor: "{{ iaas_machine_size }}" | |
network: "{{ iaas_internal_network }}" | |
- name: Delete instance | |
os_server: | |
state: absent | |
auth: '{{ auth }}' | |
name: "instance-bc4493e3fb06f3553447b2b93496a30b" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment