ansibleopenstackopenstack-nova

openstack create new instance with static ip with ansible playbook


tried to launch VM using Fixed IP While creating new Instances with Ansible Playbook without assigning/Associating floating IPs. below Playbook .. please correct me if it's working. Not able to execute the playbook.

---
- name: launch a compute instance with fixed IP
  hosts: Controllerha
  gather_facts: True
  tasks:
  - name: Creating port
    os_port:
      auth:
        auth_url: http://10.10.16.10:5000/v3/
        username: admin
        password: 2322342jkvfjlk
        project_name: admin
        project_domain_name: Default
        user_domain_name: Default
      state: present
      name: kub-mas-port1
      server: Kub-Master-1
      network: Test-VLAN
      fixed_ips:
        - ip_address: 10.200.18.18

  - name: Creating New Instance Kub VM
    os_server:
      auth:
        auth_url: http://10.10.16.10:5000/v3/
        username: Test-por
        password: Poreere1212
        project_name: test
        project_domain_name: Default
        user_domain_name: Default
      state: present
      name: Kub-Master-1
      flavor: 4V8R40G
      boot_volume: Kub-Master
      timeout: 200
      security_groups: default
      nics:
       - net-id: f7FFf-da22-4844-8c8b-0dfdfdfdde7d
       - port-name: kub-mas-port1

Solution

  • In Admin project accounts I can able to launch an instance with using the below playbook but not in other projects. There are privileges issues Somewhere in nova and Neutron roles.

    Even I added a test-pro project as an admin role. That time I found an issue with neutron service not able to add a port to the instance while running the playbook. it Went to Error state. Then I realized the problem with roles and privileges. Tried with the Admin project it's successfully rolled my playbook without any issues. Here the final playbook.

    ---
    - name: launch a compute instance
      hosts: Controller
      gather_facts: True
      tasks:
      - name: Creating port
        os_port:
          auth:
            auth_url: http://10.20.8.19:5000/v3/
            username: admin
            password: XXansereat1234???
            project_name: admin
            project_domain_name: Default
            user_domain_name: Default
          state: present
          name: kub-mas-port1
          device_owner: compute:compute-02.local
          network: Test-network
          fixed_ips:
            - ip_address: 10.200.18.18
        register: port_info
    
     
    
      - name: Creating Kub-Master VM
        os_server:
          auth:
            auth_url: http://10.20.8.19:5000/v3/
            username: admin
            password: XXansereat1234???
            project_name: admin
            project_domain_name: Default
            user_domain_name: Default
          state: present
          availability_zone: compute-02.local
          name: Kub-MasterNode
          flavor: 4V8R40G
          boot_volume: Kub-Master
          wait: yes
          nics:
           - "port-id={{ port_info.id }}"