All Projects → UpCloudLtd → Upcloud Ansible

UpCloudLtd / Upcloud Ansible

Dynamic inventory and modules for managing servers via UpCloud's API

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Upcloud Ansible

Terraform Null Ansible
Terraform Module to run ansible playbooks
Stars: ✭ 114 (+128%)
Mutual labels:  ansible, ansible-playbook, playbook
Graylog Ansible Role
Ansible role which installs and configures Graylog
Stars: ✭ 173 (+246%)
Mutual labels:  ansible, ansible-playbook, playbook
Ansible Playbook Grapher
A command line tool to create a graph representing your Ansible playbook tasks and roles
Stars: ✭ 234 (+368%)
Mutual labels:  ansible, ansible-playbook, playbook
Kubeadm Playbook
Fully fledged (HA) Kubernetes Cluster using official kubeadm, ansible and helm. Tested on RHEL/CentOS/Ubuntu with support of http_proxy, dashboard installed, ingress controller, heapster - using official helm charts
Stars: ✭ 533 (+966%)
Mutual labels:  ansible, playbook
Ansible Roles
Ansible Roles
Stars: ✭ 375 (+650%)
Mutual labels:  ansible, ansible-playbook
Ansible Role Php
Ansible Role - PHP
Stars: ✭ 396 (+692%)
Mutual labels:  ansible, playbook
Cp Ansible
Ansible playbooks for the Confluent Platform
Stars: ✭ 285 (+470%)
Mutual labels:  ansible, playbook
Ansible Role Mysql
Ansible Role - MySQL
Stars: ✭ 826 (+1552%)
Mutual labels:  ansible, playbook
Debops
DebOps - Your Debian-based data center in a box
Stars: ✭ 734 (+1368%)
Mutual labels:  ansible, playbook
Ansible Collection Gns3
Ansible Collection for GNS3 Server REST API using gns3fy
Stars: ✭ 19 (-62%)
Mutual labels:  ansible, playbook
Eos Mainnet
Ansible repo for setting up an EOS RPC API node and syncing to the mainnet
Stars: ✭ 45 (-10%)
Mutual labels:  ansible, ansible-playbook
Ansible Rails
Ansible: Ruby on Rails Server
Stars: ✭ 317 (+534%)
Mutual labels:  ansible, ansible-playbook
Mac Dev Playbook
Mac setup and configuration via Ansible.
Stars: ✭ 4,202 (+8304%)
Mutual labels:  ansible, playbook
Ansible For Devops
Ansible for DevOps examples.
Stars: ✭ 5,265 (+10430%)
Mutual labels:  ansible, playbook
Ansible Freeipa
Ansible roles and modules for FreeIPA
Stars: ✭ 284 (+468%)
Mutual labels:  ansible, playbook
Ansible Ssh Hardening
This Ansible role provides numerous security-related ssh configurations, providing all-round base protection.
Stars: ✭ 746 (+1392%)
Mutual labels:  ansible, playbook
Nagios Nrpe Server
Nagios NRPE Server Role for Ansible
Stars: ✭ 27 (-46%)
Mutual labels:  ansible, ansible-playbook
Ansible Restic
Deploy restic backup program
Stars: ✭ 29 (-42%)
Mutual labels:  ansible, ansible-playbook
Laravan
Ansible Playbooks for Laravel - machine provisioning and app deployment
Stars: ✭ 49 (-2%)
Mutual labels:  ansible, ansible-playbook
ansible-taskrunner
Ansible Taskrunner - ansible-playbook wrapper with YAML-abstracted python click cli options!
Stars: ✭ 14 (-72%)
Mutual labels:  ansible-playbook, playbook

upcloud-ansible

Dynamic inventory and modules for managing servers via UpCloud's API

The inventory script and modules contain documentation and examples as per Ansible's developer guidelines. There is an open PR for the inventory script to be included within Ansible and the plan is to open a PR for the modules to ansible-modules-extra

Dependencies and supported versions

  • upcloud-api>=0.3.4 must be installed, pip install upcloud-api or get the sources from Github
  • python 2.6 and 2.7 are supported by upcloud-api
  • tested with ansible 1.9, 2.0 and all the way to 2.8.4.
  • It should work with whatever is the newest version of ansible, if not, please create an issue about it.

Note for OS X users:

  • install ansible with homebrew can make it hard to know what Python ansible is using, using pip install ansible is recommended

Inventory script

Installation

  • move to any location you wish, point to the script with ansible -i /path/to/script/upcloud.py
  • note that upcloud.ini and upcloud.py must be in the same folder; see .ini for settings
  • you may wish to use return_ip_addresses = True in .ini to ensure that SSH works (hostnames may not be in DNS)
  • information on configuring the inventory without specifying -i every time: http://stackoverflow.com/questions/21958727/where-to-store-ansible-host-file-on-osx
  • Define upcloud api user and password in the .ini file or in env variables.
  • Default timeout is defined either in the .ini file or as env variable. (default is 300s)

Usage

# match all servers
ansible all -m ping -i /path/to/upcloud.py

# match all servers from upcloud inventory script
ansible uc-all -m ping -i /path/to/upcloud.py

# inventory group servers by upcloud Tags
ansible <any-upcloud-tag> -m <module> -i <path-to-upcloud-inventory>

UpCloud modules

Installation

  • move the modules to a location of your choice
  • make sure to add the location of your choice into library path:
  • ...or provide module path when invoking ansible:
    • ansible-playbook -M /path/to/modules/dir playbook.yml

Usage


# you can specify inventory and Modules pathes via cli
ansible-playbook create-servers.yml -i /path/to/upcloud.py -M /path/to/upcloud/modules

See the source files for documentation and examples. You may also want to refer to UpCloud's API documentation

The following example shows off some of the features of upcloud, upcloud_tag and upcloud_firewall modules:

---
- hosts: localhost
  connection: local
  serial: 1
  gather_facts: no

  tasks:
    - name: Create upcloud server
      upcloud:
        state: present
        hostname: web1.example.com
        title: web1.example.com
        zone: uk-lon1
        plan: 1xCPU-1GB
        storage_devices:
            - { size: 30, os: Ubuntu 14.04 }
            - { size: 100 }
        user: upclouduser
        ssh_keys:
            - ssh-rsa AAAAB3NzaC1yc2EAA[...]ptshi44x [email protected]me.host
            - ssh-dss AAAAB3NzaC1kc3MAA[...]VHRzAA== [email protected]
      register: upcloud_server # upcloud_server.server will contain the API response body


    # upcloud_server.public_ip shortcut will contain a public IPv4 (preferred) or IPv6 address
    # this task is not needed if host_key_checking=False in ansible
    - name: remove new server from known_hosts in case of IP collision
      known_hosts:
        state: absent
        host: "{{ upcloud_server.public_ip }}"


    - name: Wait for SSH to come up
      wait_for: host={{ upcloud_server.public_ip }} port=22 delay=5 timeout=320 state=started


    - name: tag the created server
      upcloud_tag:
        state: present
        uuid: "{{ upcloud_server.server.uuid }}"
        tags: [ webservers, london ]


    - name: configure firewall
      upcloud_firewall:
        state: present
        uuid: "{{ upcloud_server.server.uuid }}"
        firewall_rules:
        - direction: in
          family: IPv4
          protocol: udp
          destination_port_start: 53
          destination_port_end: 53
          action: accept

        - direction: in
          family: IPv4
          protocol: tcp
          destination_port_start: 22
          destination_port_end: 22
          action: accept

        - direction: in
          family: IPv4
          protocol: tcp
          destination_port_start: 80
          destination_port_end: 80
          action: accept

        - direction: in
          family: IPv4
          protocol: tcp
          destination_port_start: 443
          destination_port_end: 443
          action: accept

        # default rule last:
        - direction: in
          action: reject
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].