Giter Club home page Giter Club logo

ansible-role-nifcloud's Introduction

NIFCLOUD

Ansible role for importing module of NIFCLOUD

Build Status Coverage Status

Requirements

  • Distribution = CentOS / Ubuntu
  • python >= 2.6 or 3.x (localhost)

Role Variables

None.

Dependencies

None.

Example Playbook

  • Load libraries
hosts: servers
roles:
  - nifcloud
  • How to use libraries?
    • Refer to README.md of ansible modules for NIFCLOUD

License

This project is licensed under Apache License, Version 2.0. See LICENSE for more details.

Author Information

Fujitsu

ansible-role-nifcloud's People

Contributors

blue271828 avatar blufe avatar conhumi avatar fuku2014 avatar harikiriboy avatar heriet avatar hunter9x avatar tily avatar ykokw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ansible-role-nifcloud's Issues

Obsoleted FW options

ISSUE TYPE
  • Bug Report
SUMMARY

The following request parameters of UpdateSecurityGroup are deprecated.

  • GroupLogFilterNetBios
  • GroupLogFilterBroadcast

support python 3

ISSUE TYPE
  • Feature Idea
CORRECTION ITEMS
  1. Pip installation by get-pip.py
  2. Write urllib's import by python version

implement PrivateLAN module

  1. Run NiftyDescribePrivateLans with 1 VLAN
  2. Run NiftyCreatePrivateLan if the VLAN is not exist
  3. Run NiftyModifyPrivateLanAttribute if the specified setting value is different from the current

`No package matching 'python-pip' is available`

ISSUE TYPE
  • Bug Report
SUMMARY

stderr lines

TASK [nifcloud.nifcloud : Install python-pip (for Ubuntu)] ****************************************************************************************
task path: /path/to/.ansible/roles/nifcloud.nifcloud/tasks/ubuntu.yml:4

fatal: [localhost -> localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "name": "python-pip",
            "only_upgrade": false,
            "package": [
                "python-pip"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "upgrade": null
        }
    },
    "msg": "No package matching 'python-pip' is available"
}
STEPS TO REPRODUCE
  1. use role in Ubuntu 20.04 (localhost)
ADDITIONAL INFORMATION
  • My enviromment :
$ cat /etc/os-release                             
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

$ ansible --version                                                                         
ansible 2.8.17
  config file = /path/to/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]

$ ansible-galaxy list | grep nifcloud
- nifcloud.nifcloud, v2.2.2

The reason maybe related to the removal of python2 in Ubuntu 20.04. The python-pip package wasnt available anymore in Ubuntu 20.04 , so the command apt install python-pip (in this case is apt module) was failed.

implement ServerSeparate module

Throw error if just 2 instances are not specified
Run NiftyDescribeSeparateInstanceRules with 1 rule name
Run NiftyCreateSeparateInstanceRule with 2 instances if the rule is not exist
Run NiftyUpdateSeparateInstanceRule if the specified setting value is different from the current
Run NiftyDeregisterInstancesFromSeparateInstanceRule and NiftyRegisterInstancesWithSeparateInstanceRule if the specified 2 instances are different from the current

Add flake8 test

ISSUE TYPE
  • Feature Idea
SUMMARY

add flake8 test

STEPS TO REPRODUCE

After #34 PEP8 support , it is more better add flake8 test.

Purge ip permissions when create fw group only

I create fw rules after fw group. Because, rules contain fw group.

like this.

- name: Create Security Group
  local_action:
    module: niftycloud_fw
    state: present
    access_key: "AAA"
    secret_access_key: "BBB"
    endpoint: "east-1.cp.cloud.nifty.com"
    group_name: "fw001"

- name: Create Security Group
  local_action:
    module: niftycloud_fw
    state: present
    access_key: "AAA"
    secret_access_key: "BBB"
    endpoint: "east-1.cp.cloud.nifty.com"
    group_name: "fw002"

- name: Update Security Group
  local_action:
    module: niftycloud_fw
    state: present
    access_key: "AAA"
    secret_access_key: "BBB"
    endpoint: "east-1.cp.cloud.nifty.com"
    group_name: "fw001"
    ip_permissions:
      - in_out: "IN"
        group_name: "fw002"
        ip_protocol: "ANY"

- name: Update Security Group
  local_action:
    module: niftycloud_fw
    state: present
    access_key: "AAA"
    secret_access_key: "BBB"
    endpoint: "east-1.cp.cloud.nifty.com"
    group_name: "fw002"
    ip_permissions:
      - in_out: "IN"
        group_name: "fw001"
        ip_protocol: "ANY"

But, niftycloud_fw purge ip permissons at first create fw group.

In ec2_group imprements parameter purge_rules.
http://docs.ansible.com/ansible/ec2_group_module.html

implement PrivateLAN module

  1. Run NiftyDescribePrivateLans with 1 VLAN
  2. Run NiftyCreatePrivateLan if the VLAN is not exist
  3. Run NiftyModifyPrivateLanAttribute if the specified setting value is different from the current

Rename project to 'ansible-role-nifcloud'

ISSUE TYPE
  • Misc
SUMMARY

Rename project to ansible-role-nifcloud because NIFTYCloud has rename service to NIFCLOUD.

STEPS TO REPRODUCE
  1. Modify project settings.
  2. Modify Ansible Galaxy settings.
  3. Modify Affected files.
ADDITIONAL INFORMATION

More test case for arguments of methods

current test code looks to comfirm only response parsing

For example, in test_niftycloud.py

	# create success
	def test_create_instance_success(self):
		with mock.patch('requests.post', self.mockRequestsPostRunInstance):
			with mock.patch('niftycloud.get_instance_state', self.mockGetInstanceState16):
				self.assertEqual(
					(True, 16, 'created'),
					niftycloud.create_instance(self.mockModule)
				)

test code of create_instance method not confirm following things

  • Is it really pass arguments to requests.post method for API authentication (e.g. signature) ?
  • Is it validate arguments for create instances?

I think it should be separate test case in accordance to test purpose

Support check mode

ISSUE TYPE
  • Feature Idea
SUMMARY

see

    # the AnsibleModule object will be our abstraction working with Ansible
    # this includes instantiation, a couple of common attr would be the
    # args/params passed to the execution, as well as if the module
    # supports check mode
    module = AnsibleModule(
        argument_spec=module_args,
        supports_check_mode=True
    )

    # if the user is working with this module in only check mode we do not
    # want to make any changes to the environment, just return the current
    # state with no modifications
    if module.check_mode:
        return result
ADDITIONAL INFORMATION

niftycloud_fw failed special ip_protocol

ISSUE TYPE
  • Bug Report
SUMMARY

niftycloud_fw failed when special ip_protocol like 'SSH' and maybe others.

STEPS TO REPRODUCE

I create task like these.

- name: create fw
  local_action:
    module: niftycloud_fw
    access_key: "<ACCESS_KEY>"
    secret_access_key: "<SECRET_ACCESS_KEY>"
    endpoint: "east-1.cp.cloud.nifty.com"
    group_name: "ansibletestfw"
    availability_zone: "east-14"
    ip_permissions:
      - ip_protocol: "SSH"
        in_out: "IN"
        cidr_ip: "10.0.0.11"
    state: "present"
fatal: [localhost -> localhost]: FAILED! => {
    "changed": false, 
    "changed_attributes": {}, 
    "created": true, 
    "current_info": {
        "description": "None", 
        "group_name": "ansibletestfw", 
        "ip_permissions": [
            {
                "cidr_ip": "10.0.0.11", 
                "from_port": 22, 
                "group_name": null, 
                "in_out": "IN", 
                "ip_protocol": "TCP", 
                "to_port": 22
            }
        ], 
        "log_limit": 1000
    }, 
    "current_method": "authorize_security_group", 
    "current_state": "present", 
    "failed": true, 
    "group_name": "ansibletestfw", 
    "invocation": {
        "module_args": {
            "access_key": "<ACCESS_KEY>", 
            "availability_zone": "east-14", 
            "description": null, 
            "endpoint": "east-1.cp.cloud.nifty.com", 
            "group_name": "ansibletestfw", 
            "ip_permissions": [
                {
                    "cidr_ip": "10.0.0.11", 
                    "in_out": "IN", 
                    "ip_protocol": "SSH"
                }
            ], 
            "log_limit": null, 
            "purge_ip_permissions": true, 
            "secret_access_key": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER", 
            "state": "present"
        }, 
        "module_name": "niftycloud_fw"
    }, 
    "msg": "changes failed", 
    "status": -1
}

PLAY RECAP *********************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1 

ip_protocol like SSH is converted TCP on computing API response.

We need fix contains_ip_permissions in niftycloud_fw.py.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.