Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example from README #28

Closed
damianoneill opened this issue Apr 5, 2019 · 8 comments
Closed

Example from README #28

damianoneill opened this issue Apr 5, 2019 · 8 comments

Comments

@damianoneill
Copy link

Hi @mrlesmithjr, thanks for the role, I tried this yesterday with the example you show on the README, for the KVM setup on the host this worked fine, though I do have a question about the PR #24

My kvm_host is a bare metal centos 1810 as is the kvm_guest I'm trying to provision.

The ansible output shows that at the point where it trys to provision the guest it skips the tasks.

TASK [mrlesmithjr.kvm : config_vms | Defining VM(s)] *******************************************************************************************************************************************************************************************************************
skipping: [nuc] => (item={'name': 'red', 'autostart': True, 'boot_devices': ['cdrom', 'network', 'hd'], 'cdrom': {'source': '/root/guest.iso'}, 'graphics': False, 'disks': [{'disk_driver': 'virtio', 'name': 'red', 'size': 36864}], 'memory': 4048, 'network_interfaces': [{'source': 'default', 'network_driver': 'virtio', 'type': 'network'}], 'state': 'running', 'vcpu': 2})

TASK [mrlesmithjr.kvm : config_vms | Defining VM(s)] *******************************************************************************************************************************************************************************************************************
skipping: [nuc] => (item={'name': 'red', 'autostart': True, 'boot_devices': ['cdrom', 'network', 'hd'], 'cdrom': {'source': '/root/guest.iso'}, 'graphics': False, 'disks': [{'disk_driver': 'virtio', 'name': 'red', 'size': 36864}], 'memory': 4048, 'network_interfaces': [{'source': 'default', 'network_driver': 'virtio', 'type': 'network'}], 'state': 'running', 'vcpu': 2})

...

See below for how I've constructed the playbook. Any suggestions much appreciated.

# install the required roles
#   $ ansible-galaxy install mrlesmithjr.kvm

# create an inventory file - 
#   $ cat inventory
#   [kvm_hosts]
#   nuc
# 
#   [all:vars]
#   ansible_user=root
#   ansible_ssh_pass=xxxx
#   guest_iso_url=http://ftp.heanet.ie/pub/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso

# run the playbook 
#   $ ansible-playbook -i inventory kvm.yml


- hosts: kvm_hosts
  become: true
  tasks:
    - name: Downloading guest iso, go get a cup of tea ...
      get_url:
        url: "{{guest_iso_url}}"
        dest: /root/guest.iso
        mode: 0440

- hosts: kvm_hosts
  become: true
  vars:
    kvm_vms:
    - name: red
      autostart: true
      # Define boot devices in order of preference
      boot_devices:
        - cdrom
        - network
        - hd
      cdrom:
        source: /root/guest.iso
      graphics: false
      # Define disks in MB
      disks:
        - disk_driver: virtio
          name: red
          size: 36864
      memory: 4048
      network_interfaces:
        - source: default
          network_driver: virtio
          type: network
      state: running
      vcpu: 2
  roles:
    - role: mrlesmithjr.kvm

# see https://github.com/mrlesmithjr/ansible-kvm/pull/24 - though I dont think this is needed as I see a log entry for the same check
- hosts: kvm_hosts
  become: true
  tasks:
    - name: config_kvm | starting libvirt service 
      service: 
        name: "{{ kvm_service_name }}"
        state: started
        enabled: yes
@mrlesmithjr
Copy link
Owner

@damianoneill
Try setting kvm_manage_vms: true in your defined vars. This needs to be changed from the default kvm_manage_vms: false.

@damianoneill
Copy link
Author

@mrlesmithjr thankyou, that resolved the issue.

@mrlesmithjr
Copy link
Owner

Awesome! I have also updated the info to include this.

@damianoneill
Copy link
Author

@mrlesmithjr did you notice the question I buried in this regarding #24 ? I really should have pulled this out into separate query, just to lazy :-)

@mrlesmithjr
Copy link
Owner

I did, I haven't experienced this issue EVER, but need to look into it again.

@damianoneill
Copy link
Author

I intend blanking my host later today, will run again without explicitly setting it to started, to see what happens, will confirm later today or Monday morning.

@damianoneill
Copy link
Author

Just rebuilt the server, ran the playbook, started correctly without the explicit task, without a reboot. After reboot everything came up ok.

Looks good to me, #24 not needed.

@mrlesmithjr
Copy link
Owner

Awesome! Glad you are good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants