User Tools

Site Tools


intwtask

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
intwtask [2018/10/26 17:00]
c0rn3j created
intwtask [2018/10/26 19:46] (current)
c0rn3j
Line 90: Line 90:
  
 [Service] [Service]
-ExecStart=/bin/bash -c "/​usr/​bin/​docker system prune -af"+ExecStart=/​usr/​bin/​docker system prune -af
  
 [Install] [Install]
Line 110: Line 110:
 Save the following playbook as a file: Save the following playbook as a file:
 <​code>​ <​code>​
 +
 --- ---
 - hosts: aws - hosts: aws
Line 116: Line 117:
     - name: test connection     - name: test connection
       ping:       ping:
-    - nameChange DNS to 8.8.8.8 +    - lineinfile
-      shellif ! grep "​DNS1=8.8.8.8" ​/​etc/​sysconfig/​network-scripts/​ifcfg-eth0 ​> /dev/null; then echo "DNS1=8.8.8.8" >> /​etc/​sysconfig/​network-scripts/​ifcfg-eth0;​ chattr +/​etc/​sysconfig/​network-scripts/​ifcfg-eth0;​ fi   +        path: /​etc/​sysconfig/​network-scripts/​ifcfg-eth0 
 +        regexp: '​^DNS1='​ 
 +        line: 'DNS1=8.8.8.8
 +        attr: i
     - name: Add docker-ce repositories     - name: Add docker-ce repositories
-      ​shellyum-config-manager --add-repo ​https://​download.docker.com/​linux/​centos/​docker-ce.repo+      ​get_url: 
 +        url: https://​download.docker.com/​linux/​centos/​docker-ce.repo 
 +        dest: /​etc/​yum.repos.d/​docker-ce.repo
     - name: install docker-ce and its prereqs     - name: install docker-ce and its prereqs
       action: >       action: >
Line 149: Line 155:
         enabled: yes         enabled: yes
         state: started         state: started
-</​code>​ 
  
-# https://​bugs.launchpad.net/​cloud-init/​+bug/​1712680 +        ​ 
-#sudo nano /​etc/​sysconfig/​network-scripts/​ifcfg-eth0 +</code>
-#  DNS1=8.8.8.8 +
-#sudo chattr +i /​etc/​sysconfig/​network-scripts/ifcfg-eth0+
  
- +  ​What is the purpose of  "​docker system prune -af" systemd timer in this context and do you think this is needed? Why?
->What is the purpose of  "​docker system prune -af" systemd timer in this context and do you think this is needed? Why?+
 To always get the latest images(though I imagine there'​s a docker command for this that'd be a better solution for that). To always get the latest images(though I imagine there'​s a docker command for this that'd be a better solution for that).
 +
 It can also help if the images are somehow broken (crash or hard reboot damaged some files) by simply redownloading them periodically. It can also help if the images are somehow broken (crash or hard reboot damaged some files) by simply redownloading them periodically.
 +
 Though in this context it would fit to cleanup test dev images daily. Though in this context it would fit to cleanup test dev images daily.
  
->What is the difference, if any, of using systemd timer versus cron?+  ​What is the difference, if any, of using systemd timer versus cron?
 Harder to debug and test cron jobs vs systemd units, it's not possible to just '​systemctl start test.service'​ a cron job, you need to temporarily rewrite the execution to '* * * * *' or similar, and that's just not elegant or convenient. Harder to debug and test cron jobs vs systemd units, it's not possible to just '​systemctl start test.service'​ a cron job, you need to temporarily rewrite the execution to '* * * * *' or similar, and that's just not elegant or convenient.
-Cron has simplicity going for it though as you can't just create a script that launches on a timer in one line with systemd units.+ 
 +Cron has simplicity going for it thoughas you can't just create a script that launches on a timer in one line with systemd units.
  
 Note: The task specified the task to be ran at UTC+0. This will be done since the provided server'​s local timezone is +0, but if it weren'​t the job would run at a different time. UTC timestamps are supported in systemd 228 but Centos 7 runs a much older version of systemd - https://​github.com/​systemd/​systemd/​blob/​dd050decb6ad131ebdeabb71c4f9ecb4733269c0/​NEWS#​L23-L30 Note: The task specified the task to be ran at UTC+0. This will be done since the provided server'​s local timezone is +0, but if it weren'​t the job would run at a different time. UTC timestamps are supported in systemd 228 but Centos 7 runs a much older version of systemd - https://​github.com/​systemd/​systemd/​blob/​dd050decb6ad131ebdeabb71c4f9ecb4733269c0/​NEWS#​L23-L30
  
  
->For what purposes this setup can be used and how would you improve it?+  ​For what purposes this setup can be used and how would you improve it?
 Since the server prunes all docker images daily, I imagine this would server as a development server(cluster) where devs could create and test their images which would automatically get cleaned up daily. Since the server prunes all docker images daily, I imagine this would server as a development server(cluster) where devs could create and test their images which would automatically get cleaned up daily.
  
 Ansible could work with private IPv4 addresses instead of public ones since it's on LAN. I just used the public IPv4 for simplicity. Ansible could work with private IPv4 addresses instead of public ones since it's on LAN. I just used the public IPv4 for simplicity.
-The Ansible playbook could be rewritten so there'​s no "​shell:"​ commands. + 
-DNS not configured to 8.8.8.8 - Secondary DNS could be 1.1.1.1.+Secondary DNS could be 1.1.1.1. ​DNS is set by making a config file immutable to work around a bug in cloud-init: https://​bugs.launchpad.net/​cloud-init/​+bug/​1712680 
 The Ansible playbook seems okay, but as I first manually installed everything before turning it into a playbook, I don't have a clean-state server to verify. The Ansible playbook seems okay, but as I first manually installed everything before turning it into a playbook, I don't have a clean-state server to verify.
  
intwtask.1540573229.txt.gz · Last modified: 2018/10/26 17:00 by c0rn3j