diff --git a/defaults/main.yml b/defaults/main.yml index a9703fc..f51b734 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,8 +2,10 @@ weechat: # should we install weechat? install: true + # autostart weechat via systemd in a tmux session? + autostart: true # should we configure weechat - configure: true + configure: false # user to install and use weechat user: "{{ ansible_user_id }}" # where is our home direcotory for weechat diff --git a/files/weechat.service b/files/weechat.service new file mode 100644 index 0000000..b0658c0 --- /dev/null +++ b/files/weechat.service @@ -0,0 +1,11 @@ +[Unit] +Description=Weechat Chat Client + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/bin/tmux -2 new-session -d -s weechat /usr/bin/weechat +ExecStop=/usr/bin/tmux kill-session -t weechat + +[Install] +WantedBy=network.target diff --git a/tasks/main.yml b/tasks/main.yml index 5eff529..8588fc6 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -11,3 +11,6 @@ #- include_tasks: plugins.yml # when: configure_weechat | bool + +- include_tasks: setup_autostart.yml + when: weechat.autostart | bool diff --git a/tasks/setup_autostart.yml b/tasks/setup_autostart.yml new file mode 100644 index 0000000..4f82ff1 --- /dev/null +++ b/tasks/setup_autostart.yml @@ -0,0 +1,23 @@ +--- +- name: install tmux to launch weechat + become: true + package: + name: tmux + state: present + when: weechat.install | bool + +- name: copy systemd service for weechat + become: true + copy: + src: files/weechat.service + dest: /etc/systemd/system/weechat.service + owner: root + group: root + mode: '0644' + +- name: start and enable weechat.service + become: true + systemd: + state: started + name: weechat.service + daemon_reload: yes diff --git a/vars/main.yml b/vars/main.yml index b301a2c..6452013 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -9,13 +9,14 @@ weechat_plugin_languages: lua: lua # version management -playbook_version_number: 2050 # should be over ninethousand +playbook_version_number: 2051 # should be over ninethousand playbook_version_path: 'role-weechat_roles-ansible_github.com.version' # default values _weechat: install: true - configure: true + autostart: true + configure: false user: "{{ ansible_user_id }}" home_directory: "/home/{{ weechat_user }}/.weechat" plugins: []