Difference between revisions of "Install and configure sysstat using Ansible"

From wikieduonline
Jump to navigation Jump to search
Line 1: Line 1:
<pre>
 
#!/usr/bin/env ansible-playbook
 
  
- hosts: YOUR_HOSTNAME
+
#!/usr/bin/env ansible-playbook
  remote_user: YOUR_REMOTEUSER  
+
  become: yes
+
- hosts: YOUR_HOSTNAME
  connection: ssh
+
  remote_user: YOUR_REMOTEUSER  
 
+
  become: yes
  tasks:
+
  connection: ssh
    - name: Install and start as service sysstat for Ubuntu  
+
      block:
+
  tasks:
      - package:
+
    - name: Install and start as service sysstat for Ubuntu  
          name: sysstat
+
      block:
          state: present
+
      - package:
 
+
          name: sysstat
      - lineinfile:
+
          state: present
          path: /etc/default/sysstat
+
          state: present
+
      - lineinfile:
          backrefs: yes
+
          path: /etc/default/sysstat
          regexp: '^ENABLED="false"'
+
          state: present
          line: 'ENABLED="true"'
+
          backrefs: yes
 
+
          regexp: '^ENABLED="false"'
      - service:
+
          line: 'ENABLED="true"'
          name: sysstat
+
          state: started
+
      - service:
          enabled: yes
+
          name: sysstat
      when: ansible_distribution == 'Ubuntu'
+
            state: started
</pre>
+
          enabled: yes
 +
      when: ansible_distribution == 'Ubuntu'
  
 
== Activities ==
 
== Activities ==

Revision as of 11:15, 25 November 2020

#!/usr/bin/env ansible-playbook 

- hosts: YOUR_HOSTNAME
  remote_user: YOUR_REMOTEUSER 
  become: yes
  connection: ssh

  tasks:
    - name: Install and start as service sysstat for Ubuntu 
      block:
      - package:
          name: sysstat
          state: present	

      - lineinfile:
          path: /etc/default/sysstat
          state: present
          backrefs: yes
          regexp: '^ENABLED="false"'
          line: 'ENABLED="true"'

      - service:
          name: sysstat
           state: started
          enabled: yes
      when: ansible_distribution == 'Ubuntu'

Activities

  1. Modify Ansible playbook to include a parameters for modifying default collection interval and collection options: SADC_OPTIONS="-S XALL" in /etc/sysstat/sysstat (man sadc for more options)

See also


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using this site, you agree to the Terms of Use and Privacy Policy. Source: wikiversity

Advertising: