diff --git a/Vagrantfile b/Vagrantfile index c60ad59..b3a5133 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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. @@ -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 diff --git a/playbook.yml b/playbook.yml index 26814dd..810f35a 100644 --- a/playbook.yml +++ b/playbook.yml @@ -7,3 +7,4 @@ - nginx_redirects - retweet_bot - mumble-server + - znc_docker diff --git a/roles/znc_docker/tasks/main.yml b/roles/znc_docker/tasks/main.yml new file mode 100644 index 0000000..b5d4cbc --- /dev/null +++ b/roles/znc_docker/tasks/main.yml @@ -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 diff --git a/roles/znc_docker/templates/Dockerfile b/roles/znc_docker/templates/Dockerfile new file mode 100644 index 0000000..4282ea6 --- /dev/null +++ b/roles/znc_docker/templates/Dockerfile @@ -0,0 +1,8 @@ +FROM znc:1.6.5 + +MAINTAINER Sanyam Khurana + +RUN mkdir -p znc-data/configs/ +ADD znc.conf znc-data/configs/znc.conf + + diff --git a/roles/znc_docker/templates/znc.conf.j2 b/roles/znc_docker/templates/znc.conf.j2 new file mode 100644 index 0000000..bcee28b --- /dev/null +++ b/roles/znc_docker/templates/znc.conf.j2 @@ -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 + + Port = 3367 + IPv4 = true + IPv6 = false + SSL = false + +LoadModule = webadmin + + + Pass = {{ ZNC_ADMIN_PASS_HASH }} + Admin = true + Nick = curiouslearner + AltNick = curiouslearner_ + Ident = curiouslearner + RealName = Sanyam Khurana + LoadModule = chansaver + LoadModule = controlpanel + + + LoadModule = simple_away + Server = chat.freenode.net +6697 + + + + +