Skip to content

Commit

Permalink
Add support for Fedora 23
Browse files Browse the repository at this point in the history
  • Loading branch information
mjanser committed Nov 20, 2015
1 parent 142963d commit f220b24
Show file tree
Hide file tree
Showing 12 changed files with 106 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible Role: powerline

An Ansible role that installs powerline on Ubuntu.
An Ansible role that installs powerline on Linux.

## Requirements

Expand Down
15 changes: 10 additions & 5 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/trusty64'
config.vm.box = 'fgrehm/trusty64-lxc'

config.vm.synced_folder '.', '/vagrant', disabled: true
config.vm.synced_folder '.', '/vagrant/ansible-role-powerline'

config.vm.provider 'lxc' do |lxc, override|
override.vm.box = 'fgrehm/trusty64-lxc'
end

config.vm.provision 'shell' do |s|
s.keep_color = true
s.path = 'tests/init.sh'
end

config.vm.define 'ubuntu-trusty' do |vmconfig|
vmconfig.vm.hostname = 'ansible-role-powerline-ubuntu-trusty64'
end

config.vm.define 'fedora-23' do |vmconfig|
vmconfig.vm.hostname = 'ansible-role-powerline-fedora-23'
vmconfig.vm.box = 'obnox/fedora23-64-lxc'
end
end
5 changes: 4 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
---
galaxy_info:
author: mjanser
description: Powerline on Ubuntu
description: Installs powerline on Linux distributions
license: MIT
min_ansible_version: 1.6
platforms:
- name: Ubuntu
versions:
- trusty
- name: Fedora
versions:
- 23
categories:
- system
dependencies: []
11 changes: 11 additions & 0 deletions tasks/install-dnf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
- name: "include variables for dnf installation of powerline"
include_vars: dnf.yml

- name: "ensure packages for powerline are installed"
dnf:
name: "{{ item }}"
with_items:
- powerline
- powerline-docs
sudo: yes
17 changes: 17 additions & 0 deletions tasks/install-pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: "include variables for pip installation of powerline"
include_vars: pip.yml

- name: "ensure python pip is installed"
apt:
name: "{{ item }}"
with_items:
- git
- python-pip
sudo: yes
when: ansible_pkg_mgr == 'apt'

- name: "ensure powerline is installed"
pip:
name: powerline-status
sudo: yes
36 changes: 16 additions & 20 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
---
- name: "ensure python pip is installed"
apt:
name: "{{ item }}"
with_items:
- git
- python-pip
sudo: yes
- include: install-dnf.yml
when: "ansible_os_family == 'RedHat'"

- name: "ensure powerline is installed"
pip:
name: powerline-status
sudo: yes
- include: install-pip.yml
when: "ansible_os_family != 'RedHat'"

- name: "ensure powerline is loaded in bashrc"
copy:
src: powerline.sh
dest: /etc/profile.d/
owner: root
group: root
mode: 0644
- name: "ensure powerline is loaded in shell"
template:
src: powerline.sh.j2
dest: /etc/profile.d/powerline.sh
sudo: yes

- name: "ensure default top theme for powerline is configured"
lineinfile:
dest: /usr/local/lib/python2.7/dist-packages/powerline/config_files/config.json
dest: "{{ powerline_config_file }}"
line: "\t\t\"default_top_theme\": \"{{ powerline_default_top_theme }}\","
regexp: "default_top_theme"
insertbefore: "term_truecolor"
Expand All @@ -32,5 +22,11 @@
- name: "ensure powerline for shell is configured"
template:
src: powerline-shell.json.j2
dest: /usr/local/lib/python2.7/dist-packages/powerline/config_files/themes/shell/default.json
dest: "{{ powerline_themes_directory }}/shell/default.json"
sudo: yes

- name: "ensure powerline for tmux is configured"
template:
src: powerline-tmux.json.j2
dest: "{{ powerline_themes_directory }}/tmux/default.json"
sudo: yes
14 changes: 14 additions & 0 deletions templates/powerline-shell.json.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"segments": {
"left": [
{
"function": "powerline.segments.shell.mode"
},
{
"function": "powerline.segments.common.net.hostname",
"priority": 10
Expand All @@ -16,12 +19,23 @@
{
"function": "powerline.segments.shell.cwd",
"priority": 10
},
{
"function": "powerline.segments.shell.jobnum",
"priority": 20
}{% if powerline_shell_vcs_branch %},
{
"function": "powerline.segments.common.vcs.branch",
"priority": 40
}
{% endif %}
]
},
"segment_data": {
"branch": {
"args": {
"status_colors": true
}
}
}
}
10 changes: 10 additions & 0 deletions templates/powerline-tmux.json.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"segments": {
"right": [
{
"function": "powerline.segments.common.sys.system_load",
"priority": 50
}
]
}
}
2 changes: 1 addition & 1 deletion files/powerline.sh → templates/powerline.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ if [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/local/lib/python2.7/dist-packages/powerline/bindings/bash/powerline.sh
. {{ powerline_bindings_directory }}/bash/powerline.sh
fi
23 changes: 14 additions & 9 deletions tests/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@ export PYTHONUNBUFFERED=1
export ANSIBLE_FORCE_COLOR=1
export DEBIAN_FRONTEND=noninteractive

if ! which ansible >/dev/null; then
echo "Add APT repository"
apt-get install -qq software-properties-common &> /dev/null || exit 1
apt-add-repository ppa:ansible/ansible &> /dev/null || exit 1

apt-get update -qq

echo "Installing Ansible"
apt-get install -qq python-mysqldb ansible &> /dev/null || exit 1
if ! which ansible &>/dev/null; then
if which dnf &>/dev/null; then
echo "Installing Ansible"
dnf install -q -y ansible python-dnf >/dev/null || exit 1
else
echo "Add APT repository"
apt-get install -qq software-properties-common >/dev/null || exit 1
apt-add-repository ppa:ansible/ansible >/dev/null || exit 1

apt-get update -qq >/dev/null

echo "Installing Ansible"
apt-get install -qq ansible >/dev/null || exit 1
fi
fi


Expand Down
4 changes: 4 additions & 0 deletions vars/dnf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
powerline_config_file: /etc/xdg/powerline/config.json
powerline_themes_directory: /etc/xdg/powerline/themes
powerline_bindings_directory: /usr/share/powerline
4 changes: 4 additions & 0 deletions vars/pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
powerline_config_file: /usr/local/lib/python2.7/dist-packages/powerline/config_files/config.json
powerline_themes_directory: /usr/local/lib/python2.7/dist-packages/powerline/config_files/themes
powerline_bindings_directory: /usr/local/lib/python2.7/dist-packages/powerline/bindings

0 comments on commit f220b24

Please sign in to comment.