Select Page

Does basic upgrades and installations + install new relic

Run:

# ansible-playbook "playbook.yaml" -e gce_pem_key=/path/pemkeyfile.pem -i ./hosts -e "newrelic_key=...."

Playbook:

- name: apt upgrades and installations
  hosts: newinstance
  become: yes
  become_method: sudo
  gather_facts: no

  tasks:
  - name: initial upgrade on new instance
    apt:
      upgrade: dist
      update_cache: yes
      
  # key must be added as first
  - name: add newrelic key
    apt_key:
      url: https://download.newrelic.com/548C16BF.gpg
      state: present
    become: true
      
  - name: add newrelic repo 
    apt_repository:
      repo: deb http://apt.newrelic.com/debian/ newrelic non-free
      state: present
    become: true
    
  - name: install additional packages
    apt:
      name: "{{ item }}"
      state: present
      update_cache: yes
    with_items:
      - git
      - tmux
      - newrelic-sysmond
    become: true

  - name: set newrelic 
    replace:
      dest: /etc/newrelic/nrsysmond.cfg
      regexp: '^license_key=.*'
      replace: 'license_key={{ newrelic_key }}'
    become: true
      
  - name: restart newrelic service
    become: true
    service: 
      name: newrelic-sysmond 
      state: restarted
      enabled: true