{"id":13753703,"url":"https://github.com/ansible-provisioning/ansible-provisioning","last_synced_at":"2025-05-09T21:35:28.992Z","repository":{"id":5294453,"uuid":"6475241","full_name":"ansible-provisioning/ansible-provisioning","owner":"ansible-provisioning","description":"Ansible provisioning framework - a set of modules, plugins, and documentation for provisioning with Ansible","archived":false,"fork":false,"pushed_at":"2020-10-03T19:30:23.000Z","size":133,"stargazers_count":370,"open_issues_count":8,"forks_count":97,"subscribers_count":48,"default_branch":"master","last_synced_at":"2024-11-16T06:30:38.304Z","etag":null,"topics":["ansible","hardware","provisioning","python","virt","vmware-vsphere"],"latest_commit_sha":null,"homepage":"http://ansible.cc/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ansible-provisioning.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-31T14:33:35.000Z","updated_at":"2024-09-19T17:21:01.000Z","dependencies_parsed_at":"2022-07-05T05:01:43.255Z","dependency_job_id":null,"html_url":"https://github.com/ansible-provisioning/ansible-provisioning","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-provisioning%2Fansible-provisioning","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-provisioning%2Fansible-provisioning/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-provisioning%2Fansible-provisioning/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ansible-provisioning%2Fansible-provisioning/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ansible-provisioning","download_url":"https://codeload.github.com/ansible-provisioning/ansible-provisioning/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253328972,"owners_count":21891559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","hardware","provisioning","python","virt","vmware-vsphere"],"created_at":"2024-08-03T09:01:27.820Z","updated_at":"2025-05-09T21:35:28.574Z","avatar_url":"https://github.com/ansible-provisioning.png","language":"Python","funding_links":[],"categories":["Python","python"],"sub_categories":[],"readme":"Provisioning with Ansible\n=========================\n\nAnsible is a radically simple configuration-management, deployment, task-execution and multinode orchestration framework. Its modular design enables to extend core functionality with custom or specific needs.\n\nThis sub-project extends Ansible for provisioning so that orchestrating the installation of new systems is using the same methodology and processes as normal systems management. It includes modules for adding inventory information (facts) from external sources and modules for booting physical and virtual systems using (custom) boot media.\n\nFor more information about Ansible, read the documentation at http://ansible.com/\n\n\nModules\n=======\nWe currently provide the following modules for provisioning:\n\n - generic network information (network_facts)\n - LVM management (lvol)\n - HP iLO (hponcfg, hpilo_facts and hpilo_boot)\n - VMware vSphere (vsphere_facts and vsphere_boot)\n - KVM (virt_guest, virt_facts and virt_boot)\n - VirtualBox (vbox_facts and vbox_boot)\n - Amazon EC² (ec2_create)\n\nWe anticipate contributions from users, e.g.\n\n - IPMI (ipmi_facts and ipmi_boot)\n - IBM RSA (ibmrsa_facts and ibmrsa_boot)\n - DELL DRAC (drac_facts and drac_boot)\n - Xen (as part of virt_guest, virt_facts and virt_boot ?)\n - VirtualBox (vbox_guest)\n - VMware vSphere (vsphere_guest)\n - RHEV (rhev_guest, rhev_facts and rhev_boot)\n - Cobbler (cobbler_facts)\n - RHN (rhn_facts)\n\nAnything that adds facts to systems (wrt. provisioning and/or systems management) has a place in this repository.\n\n\nExample provisioning process\n============================\nHere is an example how you could perform the following steps:\n\n - Gather facts from separate network inventory (based on IP ranges)\n - Gather facts from HP iLO, KVM or vSphere\n - Create custom cdrom image for out-of-band ISO-based provisioning\n - Create custom PXE configuration for PXE-based provisioning\n - Boot system using ISO or PXE method\n - Clean up\n\nThe syntax of the network inventory YAML file only requires that a cidr-attribute exists for each entry. Based on the gw-option, a gateway strategy will add a gateway attribute (first or last address) if one is missing.  Everything else is optional depending on your use-case.\n\nHere is an example *network-inventory.yml*:\n```yaml\n---\n- vlan: 10\n  cidr: 10.1.10.0/25\n  description: Production servers in DMZ2\n  nameservers: [ 10.1.2.10, 10.1.3.10 ]\n  domains: [ prod.corp.intra, hw.corp.intra, mgmt.corp.intra ]\n  environment: prod\n  datacenter: brussels\n  tier: dmz2\n  gateway: 10.1.10.232\n- vlan: 15\n  cidr: 10.2.12.0/25\n  description: QA servers in DMZ3\n  nameservers: [ 10.1.2.10, 10.1.3.10 ]\n  domains: [ nonprod.corp.intra, hw.corp.intra, mgmt.corp.intra ]\n  environment: nonprod\n  datacenter: antwerp\n  tier: dmz3\n- vlan: 20\n  cidr: 10.3.148.0/22\n  description: Management servers in Trusted\n  environment: nonprod\n  datacenter: antwerp\n  tier: trusted\n```\n\nAnd here is an example of how one would be using hpilo, vsphere, kvm and network plugins for provisioning systems:\n```yaml\n- name: quick provisioning\n  hosts: all\n  gather_facts: False\n\n  vars:\n    rhel_version: 6.3\n    kickstart_file: /var/www/html/ks/{{ inventory_hostname_short }}.cfg\n    iso_image: /iso/ks/{{ inventory_hostname_short }}.iso\n    rhel_pxeboot: /var/www/mrepo/rhel{{ rhel_version }}-x86_64/disc1/images/pxeboot/.\n    isolinux_bin: /usr/share/syslinux/isolinux.bin\n\n  tasks:\n  ### Safeguard to protect production systems\n  - fail:\n      msg: 'Safeguard - System is not set to 'to-be-staged' in CMDB'\n    when: cmdb_status != 'to-be-staged'\n    delegate_to: localhost\n\n  ### Get network facts\n  - network_facts:\n      host: '{{ inventory_hostname_short }}'\n      inventory: network-inventory.yml\n      full: yes\n    delegate_to: localhost\n\n  ### Get HP iLO facts (iLO credentials from group_vars)\n  - hpilo_facts:\n      host: '{{ cmdb_parent }}'\n      login: '{{ ilologin }}'\n      password: '{{ ilopassword }}'\n    when: cmdb_hwtype.startswith('HP ')\n    delegate_to: localhost\n\n  ### Get vSphere facts (vSphere credentials group_vars, guests are named by uuid in vSphere)\n  - vsphere_facts:\n      host: '{{ cmdb_parent }}'\n      login: '{{ esxlogin }}'\n      password: '{{ esxpassword }}'\n      guest: '{{ cmdb_uuid }}'\n    when: cmdb_hwtype.startswith('VMWare ')\n    delegate_to: localhost\n\n  ### Get KVM facts (KVM hosts are managed by Ansible as well, guests are named by uuid in KVM)\n  - virt_facts:\n      guest: '{{ cmdb_uuid }}'\n    when: cmdb_hwtype.startswith('KVM')\n    delegate_to: '{{ cmdb_parent }}'\n\n  ### Create a custom boot ISO (use network_facts info for kickstart templating)\n  - command: mktemp -d\n    delegate_to: localhost\n    register: tempdir\n\n  - command: cp -av {{ rhel_pxeboot }} {{ isolinux_bin }} {{ tempdir.stdout }}\n    delegate_to: localhost\n\n  - template:\n      src: ../templates/kickstart/isolinux.cfg\n      dest: '{{ tempdir.stdout }}/isolinux.cfg'\n    delegate_to: localhost\n\n  - template:\n      src: ../templates/kickstart/ks.cfg\n      dest: '{{ tempdir.stdout }}/ks.cfg'\n    delegate_to: localhost\n\n  - command: mkisofs -r -N -allow-leading-dots -d -J -T -b isolinux.bin -c boot.cat -no-emul-boot -V \"Ansible RHEL{{ rhel_version }} for {{ inventory_hostname_short }}\" -boot-load-size 4 -boot-info-table -o {{ iso_image }} {{ tempdir.stdout }}\n    delegate_to: localhost\n\n  - command: rm -rf {{ tempdir.stdout }}\n    delegate_to: localhost\n\n  ### Create a custom kickstart and PXE configuration (based on iLO or ESX information), only one pxelinux config suffices !\n  - template:\n      src: ../templates/kickstart/ks.cfg\n      dest: {{ kickstart_file }}\n    delegate_to: localhost\n\n  - template:\n      src: ../templates/kickstart/pxelinux.cfg\n      dest: /var/lib/tftpboot/pxelinux.cfg/{{ item }}\n    with_items:\n    - {{ inventory_hostname_short }}\n    - {{ hw_product_uuid }}\n    - {{ hw_eth0.macaddress_dash }}\n    - {{ network_ipaddress_hex }}\n    delegate_to: localhost\n\n  ### Kick off HP iLO provisioning\n  - hpilo_boot:\n      host: '{{ cmdb_parent }}'\n      login: '{{ ilologin }}'\n      password: '{{ ilopassword }}'\n      media: cdrom\n      image: 'http://{{ ansible_server }}/iso/ks/{{ inventory_hostname_short }}.iso'\n      state: boot_once\n    when: cmdb_hwtype.startswith('HP ')\n    delegate_to: localhost\n\n  ### Kick off vSphere provisioning\n  - vsphere_boot:\n      host: '{{ cmdb_parent }}'\n      login: '{{ esxlogin }}'\n      password: '{{ esxpassword }}'\n      guest: '{{ cmdb_uuid }}'\n      media: cdrom\n      image: '[nfs-datastore] /iso/ks/{{ inventory_hostname_short }}.iso'\n      state: boot_once\n    when: cmdb_hwtype.startswith('VMWare ')\n    delegate_to: localhost\n\n  ### Kick off KVM provisioning\n  - virt_boot:\n      guest: '{{ cmdb_uuid }}'\n      media: cdrom\n      image: /iso/ks/{{ inventory_hostname_short }}.iso\n      state: boot_once\n    when: cmdb_hwtype.startswith('KVM')\n    delegate_to: '{{ cmdb_parent }}'\n\n  ### Revoke any existing host keys for this server (should become a separate ansible module to avoid conflicts)\n  - command: ssh-keygen -R {{ inventory_hostname_short }}\n    ignore_errors: True\n    delegate_to: localhost\n\n  ### Wait for the post-install SSH to become available\n  - wait_for:\n      host: '{{ inventory_hostname }}'\n      port: 22\n      state: started\n      timeout: 1800\n      delay: 180\n    delegate_to: localhost\n\n  ### Remove PXE boot configuration (we keep the one using the hostname_short for debugging purposes)\n  - file:\n      dest: /var/lib/tftpboot/pxelinux.cfg/{{ item }}\n      state: absent\n    with_items:\n    - {{ network_ipaddress_hex }}\n    - {{ hw_eth0.macaddress_dash }}\n    - {{ hw_product_uuid }}\n    delegate_to: localhost\n\n  ### Check if system is booted into Anaconda\n  - fail:\n      msg: 'Safeguard - System has not booted into Anaconda post-install !'\n    when: ansible_cmdline.BOOT_IMAGE is undefined\n    delegate_to: localhost\n\n  ### Now continue with configuration management by including those playbooks here !\n\n  ### Finally report success\n  - mail:\n      from: 'Provisioning of ${inventory_hostname} \u003croot\u003e'\n      to: '\u003croot\u003e'\n      cc: '\u003cyou\u003e'\n      subject: 'Server {{ inventory_hostname_short }} has been provisioned'\n      body: 'We are happy to report that server {{ inventory_hostname }} was successfully provisioned.\n\n      Here are some interesting characteristics of the server:\n\n        - Full name: {{ network_fqdn }}\n        - IP address: {{ network_ipaddress }}\n        - Model: {{ cmdb_model }}\n        - Location: {{ cmdb_parent }} / {{ cmdb_datacenter }} / {{ cmdb_location }} / {{ cmdb_rack }}\n\n      Good luck and may you find your inner peace !\n      '\n    delegate_to: localhost\n```\n\nHardware facts module interface\n===============================\nEvery facts module that returns (virtual/physical) hardware facts related to a system (using the hw_ namespace) should at least include the following facts:\n\n    hw_architecture: 'x86_64'\n    hw_eth0:\n    - macaddress: '00:11:22:33:44:55'        # MAC address of the first interface (usually used for provisioning)\n      macaddress_dash: '00-11-22-33-44-55'   # MAC address in dashed notation (for syslinux)\n    hw_product_uuid: 'ef50bac8-2845-40ff-81d9-675315501dac'\n    hw_power_status: ('on', 'off')           # Indicates the current power status\n    module_hw: true\n\nThis is necessary so that system facts can be reused in playbooks and tasks regardless of the hardware type.\n\nHardware boot module interface\n==============================\nThere is a strict set of options that each of the hardware boot modules should accept. Currently the options and values are close to what the interface to the (physical/virtual) hardware uses, but we should harmonize this so all modules accept similar options in the future.\n\nThe boot module should return the following facts:\n\n    boot_power_status: ('on', 'off')         # Indicates the power status as it was before changing it\n    module_boot: true\n\nThis is necessary so that system facts can be reused in playbooks and tasks regardless of the hardware type.\n\nHardware guest module interface\n===============================\nTBD\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansible-provisioning%2Fansible-provisioning","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fansible-provisioning%2Fansible-provisioning","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fansible-provisioning%2Fansible-provisioning/lists"}