-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote_install_playbook.yml
131 lines (111 loc) · 3.53 KB
/
remote_install_playbook.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- hosts: all
gather_facts: no
vars:
tmux_version: "3.1b"
tasks:
- name: Get installed tmux version
shell: tmux -V
register: get_tmux_ver
ignore_errors: yes
- name: Remove tmux installed from apt
apt:
name: tmux
state: absent
become: yes
when: "tmux_version not in get_tmux_ver.stdout"
- name: Install prerequisites
apt:
pkg:
- libevent-dev
- ncurses-dev
- build-essential
- bison
- pkg-config
- make
- xsel
state: latest
update_cache: yes
become: yes
when: "tmux_version not in get_tmux_ver.stdout"
- name: Create directory ~/tmuxNOC
file:
path: ~/tmuxNOC
state: directory
- name: "Download tmux version {{ tmux_version }}"
get_url:
url: "https://github.com/tmux/tmux/releases/download/{{ tmux_version }}/tmux-{{ tmux_version }}.tar.gz"
dest: ~/tmuxNOC
when: "tmux_version not in get_tmux_ver.stdout"
- name: Create temporary directory for tmux build.
tempfile:
state: directory
suffix: tmux_temp
register: tmux_temp_dir
when: "tmux_version not in get_tmux_ver.stdout"
- name: "Unpack tmux version {{ tmux_version }}"
unarchive:
src: "~/tmuxNOC/tmux-{{ tmux_version }}.tar.gz"
dest: "{{ tmux_temp_dir.path }}"
remote_src: yes
when: "tmux_version not in get_tmux_ver.stdout"
- name: Delete tmux archive
file:
path: "~/tmuxNOC/tmux-{{ tmux_version }}.tar.gz"
state: absent
when: "tmux_version not in get_tmux_ver.stdout"
- name: Run ./configure
shell: ./configure
args:
chdir: "{{ tmux_temp_dir.path }}/tmux-{{ tmux_version }}"
register: configure_output
failed_when: configure_output.stderr
when: "tmux_version not in get_tmux_ver.stdout"
- name: Make tmux from source
make:
chdir: "{{ tmux_temp_dir.path }}/tmux-{{ tmux_version }}"
when: "tmux_version not in get_tmux_ver.stdout"
- name: Install tmux
make:
chdir: "{{ tmux_temp_dir.path }}/tmux-{{ tmux_version }}"
target: install
become: yes
when: "tmux_version not in get_tmux_ver.stdout"
- name: Install or update Tmux Plugin Manager
git:
repo: https://github.com/tmux-plugins/tpm
dest: ~/tmuxNOC/plugins/tpm
- name: Checking for ~/.tmux.conf
stat:
path: ~/.tmux.conf
register: tmux_conf_file
- name: Move ~/.tmux.conf to ~/.tmux.conf.bak
shell: mv ~/.tmux.conf ~/.tmux.conf.bak
when: tmux_conf_file.stat.exists
- name: Copy .tmux.conf
copy:
src: tmux.conf
dest: ~/tmuxNOC/tmux.conf
- name: Copy tmux.remote.conf
copy:
src: tmux.remote.conf
dest: ~/tmuxNOC/tmux.remote.conf
- name: Create ~/tmuxNOC/scripts
file:
path: ~/tmuxNOC/scripts
state: directory
- name: Copy yank.sh
copy:
src: ./scripts/yank.sh
dest: ~/tmuxNOC/scripts/yank.sh
mode: '700'
- name: Link .tmux.conf with ~/tmuxNOC/tmux.conf
file:
src: ~/tmuxNOC/tmux.conf
dest: ~/.tmux.conf
state: link
- name: Installing tmux plugins
block:
- shell: tmux new -d -s __noop >/dev/null 2>&1
- shell: tmux set-environment -g TMUX_PLUGIN_MANAGER_PATH "~/tmuxNOC/plugins"
- shell: ~/tmuxNOC/plugins/tpm/bin/install_plugins
- shell: tmux kill-session -t __noop >/dev/null 2>&1