Last active
August 21, 2017 21:21
-
-
Save chianingwang/6752a8b05399179e4187c3cfb3a623c8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat elk-server-dpkg.yml | |
--- | |
# | |
# Deploying ELK stack server using .deb files | |
# | |
- name: ELK server deployment | |
hosts: elk-log-replay | |
remote_user: ss | |
become: yes | |
become_method: sudo | |
vars: | |
cert_hostname: elk-log-replay | |
tasks: | |
### INSTALL DEPENDENCIES | |
- name: Install dependencies and utilities | |
apt: | |
name: "{{item}}" | |
state: present | |
with_items: | |
- aptitude | |
- software-properties-common | |
- apt-transport-https | |
- language-pack-en | |
- python-pip | |
- vim | |
- wget | |
- curl | |
- screen | |
- zip | |
- unzip | |
- apache2-utils | |
- python-passlib | |
- default-jdk | |
- name: Create directory for installer files | |
file: | |
path: /root/installers | |
state: directory | |
mode: 0755 | |
owner: root | |
group: root | |
- name: Copy all installers to target machine | |
copy: | |
src: files/installers/ | |
dest: /root/installers | |
mode: 0755 | |
owner: root | |
group: root | |
### INSTALL ELASTICSEARCH | |
- name: Install Elasticsearch | |
apt: | |
deb: /root/installers/elasticsearch-5.5.2.deb | |
- name: Start Elasticsearch on boot | |
systemd: | |
name: elasticsearch | |
enabled: yes | |
masked: no | |
- name: Restart Elasticsearch | |
service: | |
name: elasticsearch | |
state: restarted | |
### INSTALL LOGSTASH | |
- name: Install Logstash | |
apt: | |
deb: /root/installers/logstash-5.5.2.deb | |
- name: Start Logstash on boot | |
systemd: | |
name: logstash | |
enabled: yes | |
masked: no | |
- name: Restart Logstash | |
service: | |
name: logstash | |
state: restarted | |
### INSTALL KIBANA | |
- name: Install Kibana | |
apt: | |
deb: /root/installers/kibana-5.5.2-amd64.deb | |
- name: Start Kibana on boot | |
systemd: | |
name: kibana | |
enabled: yes | |
masked: no | |
- name: Restart Kibana | |
service: | |
name: kibana | |
state: restarted | |
### INSTALL CADDY SERVER | |
- name: Untar Caddy tarball on remote host | |
unarchive: | |
src: files/installers/caddy_v0.10.6_linux_amd64.tar.gz | |
dest: /tmp | |
- name: Install Caddy Server | |
copy: | |
remote_src: True | |
src: /tmp/caddy | |
dest: /usr/local/bin/caddy | |
mode: 0755 | |
owner: root | |
group: root | |
- name: Allow Caddy to bind to privileged ports (80, 443) as non-root user | |
command: setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy | |
become: true | |
become_user: root | |
- name: Set up Caddy directory | |
file: | |
path: /etc/caddy | |
state: directory | |
mode: 0755 | |
owner: root | |
group: www-data | |
- name: Set up SSL directory for Caddy | |
file: | |
path: /etc/ssl/caddy | |
state: directory | |
mode: 0770 | |
owner: www-data | |
group: root | |
- name: Put Caddyfile w/ reverse proxy config in place | |
copy: | |
src: files/config/caddy/Caddyfile | |
dest: /etc/caddy/Caddyfile | |
mode: 0444 | |
owner: www-data | |
group: www-data | |
- name: Create Caddy log directory | |
file: | |
path: /var/log/caddy | |
state: directory | |
owner: www-data | |
group: root | |
- name: Install systemd definition for Caddy | |
copy: | |
remote_src: True | |
src: /tmp/init/linux-systemd/caddy.service | |
dest: /etc/systemd/system/caddy.service | |
mode: 0644 | |
owner: root | |
group: root | |
- name: Force systemd daemon reload | |
systemd: | |
name: caddy | |
daemon_reload: yes | |
- name: Start Caddy on boot | |
systemd: | |
name: caddy | |
enabled: yes | |
masked: no | |
- name: Restart Caddy | |
service: | |
name: caddy | |
state: restarted | |
$ hostname | |
elk-log-replay | |
$ sudo ansible-playbook -i "elk-log-replay," -c local elk-server-dpkg.yml | |
PLAY [ELK server deployment] ************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************************************************************************************** | |
ok: [elk-log-replay] | |
TASK [Install dependencies and utilities] ************************************************************************************************************************************************* | |
changed: [elk-log-replay] => (item=[u'aptitude', u'software-properties-common', u'apt-transport-https', u'language-pack-en', u'python-pip', u'vim', u'wget', u'curl', u'screen', u'zip', u'unzip', u'apache2-utils', u'python-passlib', u'default-jdk']) | |
TASK [Create directory for installer files] *********************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Copy all installers to target machine] ********************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Install Elasticsearch] ************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Start Elasticsearch on boot] ******************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart Elasticsearch] ************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Install Logstash] ******************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Start Logstash on boot] ************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Restart Logstash] ******************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Install Kibana] ********************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Start Kibana on boot] *************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart Kibana] ********************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
--- | |
TASK [Untar Caddy tarball on remote host] ************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Install Caddy Server] *************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Allow Caddy to bind to privileged ports (80, 443) as non-root user] ***************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Set up Caddy directory] ************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Set up SSL directory for Caddy] ***************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Put Caddyfile w/ reverse proxy config in place] ************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Create Caddy log directory] ********************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [Install systemd definition for Caddy] *********************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Force systemd daemon reload] ******************************************************************************************************************************************************** | |
ok: [elk-log-replay] | |
TASK [Start Caddy on boot] **************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart Caddy] ********************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
PLAY RECAP ******************************************************************************************************************************************************************************** | |
elk-log-replay : ok=24 changed=22 unreachable=0 failed=0 | |
$ sudo ansible-playbook -i "elk-log-replay," -c local elk-config.yml | |
PLAY [all] ******************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************************************************************************************** | |
ok: [elk-log-replay] | |
TASK [git] ******************************************************************************************************************************************************************************** | |
fatal: [elk-log-replay]: FAILED! => {"before": "f27386e00ecf739cc0063a6c336f005b57f26725", "changed": false, "failed": true, "msg": "Local modifications exist in repository (force=no)."} | |
to retry, use: --limit @/tmp/elk-swift/ansible/playbooks/elk/elk-config.retry | |
PLAY RECAP ******************************************************************************************************************************************************************************** | |
elk-log-replay : ok=1 changed=0 unreachable=0 failed=1 | |
$ sudo ansible-playbook -i "elk-log-replay," -c local elk-config.yml | |
PLAY [all] ******************************************************************************************************************************************************************************** | |
TASK [Gathering Facts] ******************************************************************************************************************************************************************** | |
ok: [elk-log-replay] | |
TASK [git] ******************************************************************************************************************************************************************************** | |
Username for 'https://github.com': chianingwang | |
Password for 'https://[email protected]': | |
changed: [elk-log-replay] | |
TASK [copy logstash.yml] ****************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Ensures /etc/logstash/extra_patterns/ dir exists] *********************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [copy extra_patterns/swift] ********************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Ensures /etc/logstash/conf.d/ dir exists] ******************************************************************************************************************************************* | |
ok: [elk-log-replay] | |
TASK [copy conf.d/*] ********************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [create symlink for patterns] ******************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart logstash] ******************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [copy elasticsearch/elasticsearch.yml] *********************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [uncomment line in elasticsearch.yml with cert_ip] *********************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart elasticsearch] ************************************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [copy kibana/kibana.yml] ************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
TASK [uncomment line in kibana.yml with cert_ip] ****************************************************************************************************************************************** | |
changed: [elk-log-replay] | |
TASK [Restart kibana] ********************************************************************************************************************************************************************* | |
changed: [elk-log-replay] | |
PLAY RECAP ******************************************************************************************************************************************************************************** | |
elk-log-replay : ok=15 changed=13 unreachable=0 failed=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment