SlideShare une entreprise Scribd logo
1  sur  26
Télécharger pour lire hors ligne
Managing OpenNebula
Resources with Ansible
OpenNebula Conference
Amsterdam,2018
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
FOUNDATION
2010
GAMES
Top Eleven
Golden Boot
HQ
Belgrade, Serbia
CREW
170 People,
22 Nationalities
ABOUT
WHO WE
ARE.
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
● Wasting time managing resources manually
● Several different Python scripts
● A lot of unused VMs
Problems:
Ansible Modules:
● one_vm
● one_service
● one_image
● one_image_facts
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
one_vm
The module provides the easiest way to:
● Deploy one or more instances
● Set owner, group and permissions
● Terminate,power-off and reboot instances
● Scale up/down number of instances based on specific attributes and/or
labels criteria
● Get instances info
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Create a new instance
- one_vm:
template_id: 90
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Deploy a new VM and set its name to 'foo'
- one_vm:
template_name: 'app1_template'
attributes:
name: foo
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Deploy 2 new instances and set memory, vcpu, disk_size and network
- one_vm:
template_id: 15
disk_size: 35.2 GB
memory: 4 GB
vcpu: 4
count: 2
networks:
- NETWORK_ID: 27
SECURITY_GROUPS: "10"
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
# Enforce that exactly 7 instances with attribute
# 'application: app1' are deployed
- one_vm:
template_id: 53
exact_count: 7
count_attributes:
application: app1
Scaling up/down the number of instances
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
one_service
The module provides the easiest way to:
● Create a service
● Delete a service
● Set owner, group and permissions
● Change role cardinality
● Get service info
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Instantiate a new service
- one_service:
template_id: 90
# Delete a service by ID
- one_service:
service_id: 153
state: absent
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
one_image
The module provides an easy way to manage One images, such as:
● Clone an image
● Rename an image
● Enable/Disable an image
● Delete an image
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Rename existing IMAGE
- one_image:
id: 34
state: renamed
new_name: bar-image
# Disable the IMAGE by id
- one_image:
id: 37
enabled: no
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
one_image_facts
Provides an easier way to gather facts about images using:
● image’s ids,
● name or
● regex pattern
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
# Gather facts about images using IDs
- one_image_facts:
ids:
- 123
- 456
# Gather facts about all images whose name matches regex 'app-image-.*'
- one_image_facts:
name: '~app-image-.*'
register: app_images
engineering.nordeus.com
Some of our use cases
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible
Deploying clean test environment within 90 seconds
engineering.nordeus.com
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
- name: Rename the previous used image
one_image:
name: 'Prepared Image'
state: renamed
new_name: 'Prepared Image-{{ ansible_date_time.date }}'
- name: Power Off the VM and save its disk
one_vm:
instance_ids: '{{ instances_id }}'
state: poweredoff
disk_saveas:
name: 'Prepared Image'
Deploying clean test environment within 90 seconds
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
Deploying clean test environment within 90 seconds
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
- name: Deploy test VM
one_vm:
template_name: 'Prepared Galaxy'
attributes:
name: 'galaxy-vm-{{ username }}'
galaxy_user: '{{ username }}'
networks:
- NETWORK_ID: 27
register: vm
- name: Notify user via Slack
slack:
token: '{{ slack_webhook_token }}'
msg:|
'Greetings,n IP address of your Galaxy'
'machine is {{ vm.instances[0].networks[0].ip }}'
channel: '@{{ username }}'
Deploying clean test environment within 90 seconds
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
- name: Fetch all galaxy instances
one_vm:
attributes:
galaxy_user:
labels:
- galaxy
register: old_vms
- name: Filter old instances
set_fact:
old_vms_ids: "{{ old_vms_ids }} + [ '{{ item.vm_id }}' ]"
old_vms_owners: "{{ old_vms_owners }} + ['{{ item.attributes["GALAXY_USER"]}}' ]"
with_items: '{{ old_vms.instances }}'
when: item.uptime_h|int >= uptime_h|int
Clean obsolete virtual machines
Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
- name: Terminate all obsolete instances
one_vm:
instance_ids: '{{ old_vms_ids }}'
state: absent
- name: Notify users via Slack
slack:
token: '{{ slack_webhook_token }}'
msg: "Greetings, nYour Galaxy instance is terminated, because it was too old.nCheers!"
channel: '@{{ item }}'
with_items: '{{ old_vms_owners }}'
Questions

Contenu connexe

Similaire à OpenNebulaConf2018 - Managing OpenNebula Resources with Ansible - Milan Ilic - Nordeus

Viktor Tsykunov "Microsoft AI platform for every Developer"
Viktor Tsykunov "Microsoft AI platform for every Developer"Viktor Tsykunov "Microsoft AI platform for every Developer"
Viktor Tsykunov "Microsoft AI platform for every Developer"
Lviv Startup Club
 

Similaire à OpenNebulaConf2018 - Managing OpenNebula Resources with Ansible - Milan Ilic - Nordeus (20)

Mihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate EverythingMihai Criveti - PyCon Ireland - Automate Everything
Mihai Criveti - PyCon Ireland - Automate Everything
 
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTOClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
ClickHouse on Kubernetes, by Alexander Zaitsev, Altinity CTO
 
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by  Mikael ...
WT-4069, WebCL: Enabling OpenCL Acceleration of Web Applications, by Mikael ...
 
Build containerized application using Docker and Azure.pdf
Build containerized application using Docker and Azure.pdfBuild containerized application using Docker and Azure.pdf
Build containerized application using Docker and Azure.pdf
 
Debugging Live Apps in k8s
Debugging Live Apps in k8sDebugging Live Apps in k8s
Debugging Live Apps in k8s
 
Automatización de despliegues en Openshift con Ansible Tower
Automatización de despliegues en Openshift con Ansible TowerAutomatización de despliegues en Openshift con Ansible Tower
Automatización de despliegues en Openshift con Ansible Tower
 
Viktor Tsykunov "Microsoft AI platform for every Developer"
Viktor Tsykunov "Microsoft AI platform for every Developer"Viktor Tsykunov "Microsoft AI platform for every Developer"
Viktor Tsykunov "Microsoft AI platform for every Developer"
 
DevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux ContainersDevOps Workflow: A Tutorial on Linux Containers
DevOps Workflow: A Tutorial on Linux Containers
 
Deploy Mediawiki Using FIWARE Lab Facilities
Deploy Mediawiki Using FIWARE Lab FacilitiesDeploy Mediawiki Using FIWARE Lab Facilities
Deploy Mediawiki Using FIWARE Lab Facilities
 
How to use TripleO tools for your own project
How to use TripleO tools for your own projectHow to use TripleO tools for your own project
How to use TripleO tools for your own project
 
Analyze This! CloudBees Jenkins Cluster Operations and Analytics
Analyze This! CloudBees Jenkins Cluster Operations and AnalyticsAnalyze This! CloudBees Jenkins Cluster Operations and Analytics
Analyze This! CloudBees Jenkins Cluster Operations and Analytics
 
Deploy MediaWiki usgin Fiware Lab Facilities
Deploy MediaWiki usgin Fiware Lab FacilitiesDeploy MediaWiki usgin Fiware Lab Facilities
Deploy MediaWiki usgin Fiware Lab Facilities
 
Salesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer featuresSalesforce Winter 20 interesting developer features
Salesforce Winter 20 interesting developer features
 
Scylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for KubernetesScylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
Scylla Summit 2022: What’s New in ScyllaDB Operator for Kubernetes
 
Iac d.damyanov 4.pptx
Iac d.damyanov 4.pptxIac d.damyanov 4.pptx
Iac d.damyanov 4.pptx
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 
Neo4j on Azure Step by Step
Neo4j on Azure Step by StepNeo4j on Azure Step by Step
Neo4j on Azure Step by Step
 
CI/CD Across Multiple Environments
CI/CD Across Multiple EnvironmentsCI/CD Across Multiple Environments
CI/CD Across Multiple Environments
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
ELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot TimesELC-E 2010: The Right Approach to Minimal Boot Times
ELC-E 2010: The Right Approach to Minimal Boot Times
 

Plus de OpenNebula Project

OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
OpenNebula Project
 

Plus de OpenNebula Project (20)

OpenNebulaConf2019 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2019 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...OpenNebulaConf2019 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
OpenNebulaConf2019 - Welcome and Project Update - Ignacio M. Llorente, Rubén ...
 
OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
OpenNebulaConf2019 - Building Virtual Environments for Security Analyses of C...
 
OpenNebulaConf2019 - CORD and Edge computing with OpenNebula - Alfonso Aureli...
OpenNebulaConf2019 - CORD and Edge computing with OpenNebula - Alfonso Aureli...OpenNebulaConf2019 - CORD and Edge computing with OpenNebula - Alfonso Aureli...
OpenNebulaConf2019 - CORD and Edge computing with OpenNebula - Alfonso Aureli...
 
OpenNebulaConf2019 - 6 years (+) OpenNebula - Lessons learned - Sebastian Man...
OpenNebulaConf2019 - 6 years (+) OpenNebula - Lessons learned - Sebastian Man...OpenNebulaConf2019 - 6 years (+) OpenNebula - Lessons learned - Sebastian Man...
OpenNebulaConf2019 - 6 years (+) OpenNebula - Lessons learned - Sebastian Man...
 
OpenNebulaConf2019 - Performant and Resilient Storage the Open Source & Linux...
OpenNebulaConf2019 - Performant and Resilient Storage the Open Source & Linux...OpenNebulaConf2019 - Performant and Resilient Storage the Open Source & Linux...
OpenNebulaConf2019 - Performant and Resilient Storage the Open Source & Linux...
 
OpenNebulaConf2019 - Image Backups in OpenNebula - Momčilo Medić - ITAF
OpenNebulaConf2019 - Image Backups in OpenNebula - Momčilo Medić - ITAFOpenNebulaConf2019 - Image Backups in OpenNebula - Momčilo Medić - ITAF
OpenNebulaConf2019 - Image Backups in OpenNebula - Momčilo Medić - ITAF
 
OpenNebulaConf2019 - How We Use GOCA to Manage our OpenNebula Cloud - Jean-Ph...
OpenNebulaConf2019 - How We Use GOCA to Manage our OpenNebula Cloud - Jean-Ph...OpenNebulaConf2019 - How We Use GOCA to Manage our OpenNebula Cloud - Jean-Ph...
OpenNebulaConf2019 - How We Use GOCA to Manage our OpenNebula Cloud - Jean-Ph...
 
OpenNebulaConf2019 - Crytek: A Video gaming Edge Implementation "on the shoul...
OpenNebulaConf2019 - Crytek: A Video gaming Edge Implementation "on the shoul...OpenNebulaConf2019 - Crytek: A Video gaming Edge Implementation "on the shoul...
OpenNebulaConf2019 - Crytek: A Video gaming Edge Implementation "on the shoul...
 
Replacing vCloud with OpenNebula
Replacing vCloud with OpenNebulaReplacing vCloud with OpenNebula
Replacing vCloud with OpenNebula
 
NTS: What We Do With OpenNebula - and Why We Do It
NTS: What We Do With OpenNebula - and Why We Do ItNTS: What We Do With OpenNebula - and Why We Do It
NTS: What We Do With OpenNebula - and Why We Do It
 
OpenNebula from the Perspective of an ISP
OpenNebula from the Perspective of an ISPOpenNebula from the Perspective of an ISP
OpenNebula from the Perspective of an ISP
 
NTS CAPTAIN / OpenNebula at Julius Blum GmbH
NTS CAPTAIN / OpenNebula at Julius Blum GmbHNTS CAPTAIN / OpenNebula at Julius Blum GmbH
NTS CAPTAIN / OpenNebula at Julius Blum GmbH
 
Performant and Resilient Storage: The Open Source & Linux Way
Performant and Resilient Storage: The Open Source & Linux WayPerformant and Resilient Storage: The Open Source & Linux Way
Performant and Resilient Storage: The Open Source & Linux Way
 
NetApp Hybrid Cloud with OpenNebula
NetApp Hybrid Cloud with OpenNebulaNetApp Hybrid Cloud with OpenNebula
NetApp Hybrid Cloud with OpenNebula
 
NSX with OpenNebula - upcoming 5.10
NSX with OpenNebula - upcoming 5.10NSX with OpenNebula - upcoming 5.10
NSX with OpenNebula - upcoming 5.10
 
Security for Private Cloud Environments
Security for Private Cloud EnvironmentsSecurity for Private Cloud Environments
Security for Private Cloud Environments
 
CheckPoint R80.30 Installation on OpenNebula
CheckPoint R80.30 Installation on OpenNebulaCheckPoint R80.30 Installation on OpenNebula
CheckPoint R80.30 Installation on OpenNebula
 
DE-CIX: CloudConnectivity
DE-CIX: CloudConnectivityDE-CIX: CloudConnectivity
DE-CIX: CloudConnectivity
 
DDC Demo
DDC DemoDDC Demo
DDC Demo
 
Cloud Disaggregation with OpenNebula
Cloud Disaggregation with OpenNebulaCloud Disaggregation with OpenNebula
Cloud Disaggregation with OpenNebula
 

Dernier

CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
anilsa9823
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 

Dernier (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

OpenNebulaConf2018 - Managing OpenNebula Resources with Ansible - Milan Ilic - Nordeus

  • 1. Managing OpenNebula Resources with Ansible OpenNebula Conference Amsterdam,2018
  • 2. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com FOUNDATION 2010 GAMES Top Eleven Golden Boot HQ Belgrade, Serbia CREW 170 People, 22 Nationalities ABOUT WHO WE ARE.
  • 3.
  • 4. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com
  • 5. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com ● Wasting time managing resources manually ● Several different Python scripts ● A lot of unused VMs Problems:
  • 6.
  • 7. Ansible Modules: ● one_vm ● one_service ● one_image ● one_image_facts
  • 8. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible one_vm The module provides the easiest way to: ● Deploy one or more instances ● Set owner, group and permissions ● Terminate,power-off and reboot instances ● Scale up/down number of instances based on specific attributes and/or labels criteria ● Get instances info engineering.nordeus.com
  • 9. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Create a new instance - one_vm: template_id: 90 engineering.nordeus.com
  • 10. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Deploy a new VM and set its name to 'foo' - one_vm: template_name: 'app1_template' attributes: name: foo engineering.nordeus.com
  • 11. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Deploy 2 new instances and set memory, vcpu, disk_size and network - one_vm: template_id: 15 disk_size: 35.2 GB memory: 4 GB vcpu: 4 count: 2 networks: - NETWORK_ID: 27 SECURITY_GROUPS: "10" engineering.nordeus.com
  • 12. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com # Enforce that exactly 7 instances with attribute # 'application: app1' are deployed - one_vm: template_id: 53 exact_count: 7 count_attributes: application: app1 Scaling up/down the number of instances
  • 13. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible one_service The module provides the easiest way to: ● Create a service ● Delete a service ● Set owner, group and permissions ● Change role cardinality ● Get service info engineering.nordeus.com
  • 14. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Instantiate a new service - one_service: template_id: 90 # Delete a service by ID - one_service: service_id: 153 state: absent engineering.nordeus.com
  • 15. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible one_image The module provides an easy way to manage One images, such as: ● Clone an image ● Rename an image ● Enable/Disable an image ● Delete an image engineering.nordeus.com
  • 16. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Rename existing IMAGE - one_image: id: 34 state: renamed new_name: bar-image # Disable the IMAGE by id - one_image: id: 37 enabled: no engineering.nordeus.com
  • 17. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible one_image_facts Provides an easier way to gather facts about images using: ● image’s ids, ● name or ● regex pattern engineering.nordeus.com
  • 18. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible # Gather facts about images using IDs - one_image_facts: ids: - 123 - 456 # Gather facts about all images whose name matches regex 'app-image-.*' - one_image_facts: name: '~app-image-.*' register: app_images engineering.nordeus.com
  • 19. Some of our use cases
  • 20. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible Deploying clean test environment within 90 seconds engineering.nordeus.com
  • 21. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com - name: Rename the previous used image one_image: name: 'Prepared Image' state: renamed new_name: 'Prepared Image-{{ ansible_date_time.date }}' - name: Power Off the VM and save its disk one_vm: instance_ids: '{{ instances_id }}' state: poweredoff disk_saveas: name: 'Prepared Image' Deploying clean test environment within 90 seconds
  • 22. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com Deploying clean test environment within 90 seconds
  • 23. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com - name: Deploy test VM one_vm: template_name: 'Prepared Galaxy' attributes: name: 'galaxy-vm-{{ username }}' galaxy_user: '{{ username }}' networks: - NETWORK_ID: 27 register: vm - name: Notify user via Slack slack: token: '{{ slack_webhook_token }}' msg:| 'Greetings,n IP address of your Galaxy' 'machine is {{ vm.instances[0].networks[0].ip }}' channel: '@{{ username }}' Deploying clean test environment within 90 seconds
  • 24. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com - name: Fetch all galaxy instances one_vm: attributes: galaxy_user: labels: - galaxy register: old_vms - name: Filter old instances set_fact: old_vms_ids: "{{ old_vms_ids }} + [ '{{ item.vm_id }}' ]" old_vms_owners: "{{ old_vms_owners }} + ['{{ item.attributes["GALAXY_USER"]}}' ]" with_items: '{{ old_vms.instances }}' when: item.uptime_h|int >= uptime_h|int Clean obsolete virtual machines
  • 25. Milan Ilić, System EngineerManaging OpenNebula Resources with Ansible engineering.nordeus.com - name: Terminate all obsolete instances one_vm: instance_ids: '{{ old_vms_ids }}' state: absent - name: Notify users via Slack slack: token: '{{ slack_webhook_token }}' msg: "Greetings, nYour Galaxy instance is terminated, because it was too old.nCheers!" channel: '@{{ item }}' with_items: '{{ old_vms_owners }}'