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

new: Add module to manage placement group assignment #510

Merged

Conversation

yec-akamai
Copy link
Contributor

📝 Description

Add a new module placement_group_assign to manage the 1:1 assignment between a Linode and a placement group.

✔️ How to Test

Run pip install --force -r requirements.txt to install required dependencies.

Also, you need to set up environment variables to test against alpha:

export TEST_API_CA=$PWD/cacert.pem
export TEST_API_URL=https://.../
export LINODE_TOKEN=...
make TEST_ARGS="-v placement_group_assign" test

Manual test:

  1. In a sandbox environment, i.e. dx-dvenv, run the following ansible playbook
- name: ansible_linode Sandbox Playbook
  hosts: localhost
  tasks:
    - name: Create a Linode placement group
      linode.cloud.placement_group:
        label: my-ansible-test-pg
        region: us-east
        affinity_type: anti_affinity:local
        state: present
      register: pg_created

    - name: Create a Linode instance
      linode.cloud.instance:
        label: test-pg-instance
        type: g6-nanode-1
        region: us-east
        state: present
      register: instance

    - name: Assign Linode to the placement group
      linode.cloud.placement_group_assign:
        placement_group_id: '{{ pg_created.placement_group.id }}'
        linode_id: '{{ instance.instance.id }}'
        state: present
      register: pg_assign

    - name: Get placement group info
      linode.cloud.placement_group_info:
        id: '{{ pg_created.placement_group.id }}'
      register: pg_assign_info
  1. Observe that the Linode is successfully assigned to the placement group. And it appears in the members of the placement group info.

  2. Run the following playbook to unassign from the placement group

    - name: Unassign Linode to the placement group
      linode.cloud.placement_group_assign:
        placement_group_id: '{{ pg_created.placement_group.id }}'
        linode_id: '{{ instance.instance.id }}'
        state: absent
      register: pg_unassign

    - name: Get placement group info
      linode.cloud.placement_group_info:
        id: '{{ pg_created.placement_group.id }}'
      register: pg_unassign_info
  1. Observe that the Linode is removed from the placement group members.

@yec-akamai yec-akamai added the new-feature for new features in the changelog. label May 29, 2024
@yec-akamai yec-akamai requested a review from a team as a code owner May 29, 2024 17:00
@yec-akamai yec-akamai requested review from jriddle-linode and zliang-akamai and removed request for a team May 29, 2024 17:00
Copy link
Member

@zliang-akamai zliang-akamai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well locally. Nice job!

Copy link
Collaborator

@jriddle-linode jriddle-linode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yec-akamai yec-akamai merged commit 0c39074 into linode:proj/vm-placement Jun 18, 2024
4 checks passed
@yec-akamai yec-akamai deleted the TPT-2902/add-vmp-assign branch June 18, 2024 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new-feature for new features in the changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants