Commit 5a3e62b4 authored by Florian Kempenich's avatar Florian Kempenich
Browse files

Fix glances installation

parent 1c114dad
################################################ ################################################
## This playbook has 3 steps: ## This playbook has 2 steps:
## 1) Create Droplet on DigitalOcean & Update inventory / ssh config ## 1) Create Droplet on DigitalOcean & Update inventory / ssh config
## 2) Create new User account on Droplet ## 2) Create new User account on Droplet
## 3) Install Software w/ new User account
## ##
## ##
## These steps are run on different machines w/ different users: ## These steps are run on different machines w/ different users:
...@@ -12,9 +11,6 @@ ...@@ -12,9 +11,6 @@
## 2) Create new User account ... ## 2) Create new User account ...
## -> Runs on: Newly Created Droplet ## -> Runs on: Newly Created Droplet
## -> as: root ## -> as: root
## 3) Install Software ...
## -> Runs on: Newly Created Droplet
## -> as: Newly Created User
##################################################################### #####################################################################
...@@ -132,6 +128,13 @@ ...@@ -132,6 +128,13 @@
vars: vars:
swapfile_size: "{{ droplet_specs.swap }}" swapfile_size: "{{ droplet_specs.swap }}"
- name: "Install Glances Webserver as a service"
include_role:
name: glances
- name: "Enable advanced metrics on DigitalOcean"
shell: "curl -sSL https://agent.digitalocean.com/install.sh | sh"
- name: "Create new sudo user w/ default password" - name: "Create new sudo user w/ default password"
include_role: include_role:
name: create-new-sudo-user name: create-new-sudo-user
...@@ -140,50 +143,14 @@ ...@@ -140,50 +143,14 @@
default_password: "{{ user_to_create_default_password }}" default_password: "{{ user_to_create_default_password }}"
authorized_ssh_key: "{{ ssh_pub_key_to_load_on_droplet }}" authorized_ssh_key: "{{ ssh_pub_key_to_load_on_droplet }}"
- debug:
msg:
##################################################################### - "Droplet '{{ droplet_name }}' succesfuly created"
### STEP 3 ## - ""
### Install Software w/ new User account ## - "IP = {{ ansible_default_ipv4.address }}"
### ## - "User = {{ user_to_create_username }}"
### Host: Newly Created Droplet ## - "Password = {{ user_to_create_default_password }}"
### SSH User: Newly Created User ## - "Glance server running at: http://138.68.100.84:61208"
##################################################################### - ""
- hosts: "{{ droplet_name }}" - "You can now ssh to the droplet with `ssh {{ droplet_name }}`"
gather_facts: False - "Don't forget to change the default password!"
vars:
# If using `remote_user` at the same level as `hosts`, it would
# not override the `ansible_user` variable from the inventory
ansible_user: "{{ user_to_create_username }}"
ansible_become_pass: "{{ user_to_create_default_password }}"
tasks:
- name: Try Block
block:
# TODO: Fix Glances installation (or remove, but be sure to re-locate the daemon part!!)
# TODO: Fix Glances installation (or remove, but be sure to re-locate the daemon part!!)
# TODO: Fix Glances installation (or remove, but be sure to re-locate the daemon part!!)
# - name: "Install Glances Webserver as a service"
# include_role:
# name: glances
- name: "Enable advanced metrics on DigitalOcean"
shell: "curl -sSL https://agent.digitalocean.com/install.sh | sh"
become: yes
- debug:
msg:
- "Droplet '{{ droplet_name }}' succesfuly created"
- ""
- "IP = {{ ansible_default_ipv4.address }}"
- "User = {{ user_to_create_username }}"
- "Password = {{ user_to_create_default_password }}"
- ""
- "You can now ssh to the droplet with `ssh {{ droplet_name }}`"
- "Don't forget to change the default password!"
rescue:
- debug:
msg:
- "Problem during setup!"
- "Is it the first time this is ran?"
- "If not, did you change the sudo password for the default user?"
\ No newline at end of file
...@@ -3,7 +3,7 @@ Description=Glances Webserver on port 61208 ...@@ -3,7 +3,7 @@ Description=Glances Webserver on port 61208
[Service] [Service]
After=network.target After=network.target
ExecStart=/usr/local/bin/glances -w ExecStart=/root/.local/bin/glances -w
Restart=on-abort Restart=on-abort
[Install] [Install]
......
- name: "Ensure running as Root"
assert:
that:
- "{{ ansible_user_uid }} == 0"
msg: "Please run this role as root!"
- name: "Install Glances" - name: "Install Glances"
block: block:
- name: "Install `pip3`" - name: "Install `pip3`"
...@@ -5,32 +11,25 @@ ...@@ -5,32 +11,25 @@
name: python3-pip name: python3-pip
state: latest state: latest
update_cache: yes update_cache: yes
become: yes
- name: "Upgrade `pip3`" - name: "Upgrade `pip3`"
pip: pip:
name: pip name: pip
executable: pip3 executable: pip3
state: latest state: latest
become: yes
- name: "Install `glances`"
pip:
name: glances
executable: pip3
state: latest
become: yes
- name: "Install `glances` optional dependencies" - name: "Install `glances` and `glances` optional dependencies"
pip: pip:
name: "{{ item }}" name: "{{ item }}"
executable: pip3 executable: pip3
state: latest state: latest
become: yes extra_args: --user
with_items: with_items:
- glances
- docker - docker
- bottle - bottle
- name: "Start Glances Web server as Daemon" - name: "Start Glances Web server as Daemon"
block: block:
- name: "Copy `glances.service` file" - name: "Copy `glances.service` file"
...@@ -45,4 +44,4 @@ ...@@ -45,4 +44,4 @@
name: glances.service name: glances.service
state: started state: started
enabled: yes enabled: yes
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment