Showing posts with label ansible. Show all posts
Showing posts with label ansible. Show all posts

2016-08-07

installing splunkforwarder using ansible

The vars
---
  splunk_home: /opt/splunkforwarder
  splunk_exec: "{{ splunk_home }}/bin/splunk"


The playbook
---

- name: install splunk forwarder
  yum: name=splunkforwarder
       state=latest
  become: yes

# check for first time run
- stat:
    path: "{{ splunk_home }}/ftr"
  register: result_splunk_ftr_stat

- block:
    - name: setup splunk for first time run
      shell: |
        ps aux|grep splunkd && pkill -9 splunkd || true
        {{ splunk_exec }} start --accept-license --answer-yes --no-prompt
        {{ splunk_exec }} enable boot-start
  when: result_splunk_ftr_stat.stat.exists
  become: yes


# Only add servers which are not in list
# shell: /opt/splunkforwarder/bin/splunk list forward-server -auth user:pass
# register: current_fwd_list
#- block:
#    shell: "{{ splunk_exec }} add forward-server {{ splunk_server }}:{{ splunk_server_port }} -auth user:pass"
# when: item not in current_fwd_list
#  become: yes
# with_items: splunk_fwd_server

# same logic for adding logs
#    - shell: "{{ splunk_exec }} add monitor {{ item.path }} -index {{ item.idx }} -sourcetype {{ item.path }} || true"
#  with_items:  "{{ splunk_log_files }}"

and profit !

2016-06-22

adding authorized keys using ansible


You can use jinja template engine to set this

vars:
  ssh_user_key:
    - user: ritesh
      exclusive: no
      keys:
        - ritesh.centos
        - ritesh.fedora

- name: ssh user key upload
  authorized_key:
    user: "{{ item.user }}"
    exclusive: "{{ item.exclusive if item.exclusive is defined else 'no' }}"
    key: "{% for file_name in item['keys'] %} {{ key|default('') + lookup('file', file_name) }}{% if not loop.last %}{{ '\n' }}{% endif %} {% endfor %}"
  become_user: "{{ item.user }}"
  become: yes

  with_items:
    - "{{ ssh_user_key }}"
  tags:
    - setup-user-ssh-client-key



adding authorized keys using ansible


You can use jinja template engine to set this

vars:
  ssh_user_key:
    - user: ritesh
      exclusive: no
      keys:
        - ritesh.centos
        - ritesh.fedora

- name: ssh user key upload
  authorized_key:
    user: "{{ item.user }}"
    exclusive: "{{ item.exclusive if item.exclusive is defined else 'no' }}"
    key: "{% for file_name in item['keys'] %} {{ key|default('') + lookup('file', file_name) }}{% if not loop.last %}{{ '\n' }}{% endif %} {% endfor %}"
  become_user: "{{ item.user }}"
  become: yes

  with_items:
    - "{{ ssh_user_key }}"
  tags:
    - setup-user-ssh-client-key



GitLab runner on Windows with bash shell on windows contianer on Docker

As part of your pipeline, you may need to perform browser testing across different platforms/environments. To minimize testing time, it'...