Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Docker container for running ZNC #17

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Vagrant.configure(2) do |config|
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network "forwarded_port", guest: 80, host: 8080
config.vm.network "forwarded_port", guest: 36697, host: 36697

# Create a private network, which allows host-only access to the machine
# using a specific IP.
Expand Down Expand Up @@ -69,5 +70,8 @@ Vagrant.configure(2) do |config|
ansible.inventory_path = "hosts"
ansible.verbose = "vvv"
ansible.limit = "vagrant"
ansible.extra_vars = {
ZNC_ADMIN_PASS_HASH: "sha256#0be7da92c5c868ed70c76629610b6b6791bf17a89ce46bcb7ee91b058da96928#x56AIGENv2nr3_7G:xrn#"
}
end
end
1 change: 1 addition & 0 deletions playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- nginx_redirects
- retweet_bot
- mumble-server
- znc_docker
82 changes: 82 additions & 0 deletions roles/znc_docker/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---

- name: add docker apt key
apt_key:
keyserver: hkp://p80.pool.sks-keyservers.net:80
id: 58118E89F3A912897C070ADBF76221572C52609D
tags:
- configure

- name: add docker apt repository
apt_repository:
repo: deb https://apt.dockerproject.org/repo ubuntu-trusty main
update_cache: yes
tags:
- configure

- name: ensure docker and dependencies are installed
apt: name=docker-engine update_cache=yes
tags:
- configure

- service: name=docker state=restarted
tags:
- configure

- name: Install Docker py
pip:
name: docker-py
tags:
- configure

- name: create /srv/znc dir and give permission
file: path=/srv/znc owner={{ ansible_ssh_user }} group={{ ansible_ssh_user }} mode=0775 state=directory recurse=yes
sudo: yes
tags:
- configure

- name: create ~/.znc dir and give permission
file: path=~/.znc/configs owner={{ ansible_ssh_user }} group={{ ansible_ssh_user }} mode=0775 state=directory recurse=yes
sudo: yes
tags:
- configure

- name: Copy Dockerfile
template: src=Dockerfile dest=/srv/znc/Dockerfile
tags:
- configure

- name: Copy ZNC conf
template: src=znc.conf.j2 dest=~/.znc/configs/znc.conf
environment:
ZNC_ADMIN_PASS_HASH: "{{ lookup('env', 'ZNC_ADMIN_PASS_HASH') }}"
tags:
- configure

- name: build image
docker_image: >
name="curiouslearner/znc"
tag="0.1"
path="/srv/znc"
state=build
tags:
- configure

- name: Stop running ZNC instance
shell: docker stop pydelhi_znc
sudo: yes
tags:
- deploy

- name: Remove stopped ZNC instance
shell: docker rm pydelhi_znc
sudo: yes
tags:
- deploy

- name: Run ZNC instance
shell: docker run --name pydelhi_znc -d -p 36697:6697 -v ~/.znc:/znc-data curiouslearner/znc:0.1
sudo: yes
tags:
- configure
- deploy
8 changes: 8 additions & 0 deletions roles/znc_docker/templates/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM znc:1.6.5

MAINTAINER Sanyam Khurana <[email protected]>

RUN mkdir -p znc-data/configs/
ADD znc.conf znc-data/configs/znc.conf


37 changes: 37 additions & 0 deletions roles/znc_docker/templates/znc.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// WARNING
//
// Do NOT edit this file while ZNC is running!
// Use webadmin or *controlpanel instead.
//
// Altering this file by hand will forfeit all support.
//
// But if you feel risky, you might want to read help on /znc saveconfig and /znc rehash.
// Also check http://en.znc.in/wiki/Configuration

Version = 1.6.5
<Listener l>
Port = 3367
IPv4 = true
IPv6 = false
SSL = false
</Listener>
LoadModule = webadmin

<User curiouslearner>
Pass = {{ ZNC_ADMIN_PASS_HASH }}
Admin = true
Nick = curiouslearner
AltNick = curiouslearner_
Ident = curiouslearner
RealName = Sanyam Khurana
LoadModule = chansaver
LoadModule = controlpanel

<Network freenode>
LoadModule = simple_away
Server = chat.freenode.net +6697

<Chan #pydelhi>
</Chan>
</Network>
</User>