mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
20150106-1 选题
This commit is contained in:
parent
9b4d773824
commit
ee0e950255
@ -0,0 +1,59 @@
|
||||
This App Can Write a Single ISO to 20 USB Drives Simultaneously
|
||||
================================================================================
|
||||
**If I were to ask you to burn a single Linux ISO to 17 USB thumb drives how would you go about doing it?**
|
||||
|
||||
Code savvy folks would write a little bash script to automate the process, and a large number would use a GUI tool like the USB Startup Disk Creator to burn the ISO to each drive in turn, one by one. But the rest of us would fast conclude that neither method is ideal.
|
||||
|
||||
### Problem > Solution ###
|
||||
|
||||
![GNOME MultiWriter in action](http://www.omgubuntu.co.uk/wp-content/uploads/2015/01/gnome-multi-writer.jpg)
|
||||
|
||||
GNOME MultiWriter in action
|
||||
|
||||
Richard Hughes, a GNOME developer, faced a similar dilemma. He wanted to create a number of USB drives pre-loaded with an OS, but wanted a tool simple enough for someone like his dad to use.
|
||||
|
||||
His response was to create a **brand new app** that combines both approaches into one easy to use tool.
|
||||
|
||||
It’s called “[GNOME MultiWriter][1]” and lets you write a single ISO or IMG to multiple USB drives at the same time.
|
||||
|
||||
It nixes the need to customize or create a command line script and relinquishes the need to waste an afternoon performing an identical set of actions on repeat.
|
||||
|
||||
All you need is this app, an ISO, some thumb-drives and lots of empty USB ports.
|
||||
|
||||
### Use Cases and Installing ###
|
||||
|
||||
![The app can be installed on Ubuntu](http://www.omgubuntu.co.uk/wp-content/uploads/2015/01/mutli-writer-on-ubuntu.jpg)
|
||||
|
||||
The app can be installed on Ubuntu
|
||||
|
||||
The app has a pretty defined usage scenario, that being situations where USB sticks pre-loaded with an OS or live image are being distributed.
|
||||
|
||||
That being said, it should work just as well for anyone wanting to create a solitary bootable USB stick, too — and since I’ve never once successfully created a bootable image from Ubuntu’s built-in disk creator utility, working alternatives are welcome news to me!
|
||||
|
||||
Hughes, the developer, says it **supports up to 20 USB drives**, each being between 1GB and 32GB in size.
|
||||
|
||||
The drawback (for now) is that GNOME MultiWriter is not a finished, stable product. It works, but at this early blush there are no pre-built binaries to install or a PPA to add to your overstocked software sources.
|
||||
|
||||
If you know your way around the usual configure/make process you can get it up and running in no time. On Ubuntu 14.10 you may also need to install the following packages first:
|
||||
|
||||
sudo apt-get install gnome-common yelp-tools libcanberra-gtk3-dev libudisks2-dev gobject-introspection
|
||||
|
||||
If you get it up and running, give it a whirl and let us know what you think!
|
||||
|
||||
Bugs and pull requests can be longed on the GitHub page for the project, which is where you’ll also found tarball downloads for manual installation.
|
||||
|
||||
- [GNOME MultiWriter on Github][2]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.omgubuntu.co.uk/2015/01/gnome-multiwriter-iso-usb-utility
|
||||
|
||||
作者:[Joey-Elijah Sneddon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117485690627814051450/?rel=author
|
||||
[1]:https://github.com/hughsie/gnome-multi-writer/
|
||||
[2]:https://github.com/hughsie/gnome-multi-writer/
|
@ -0,0 +1,47 @@
|
||||
2015: Open Source Has Won, But It Isn't Finished
|
||||
================================================================================
|
||||
> After the wins of 2014, what's next?
|
||||
|
||||
At the beginning of a new year, it's traditional to look back over the last 12 months. But as far as this column is concerned, it's easy to summarise what happened then: open source has won. Let's take it from the top:
|
||||
|
||||
**Supercomputers**. Linux is so dominant on the Top 500 Supercomputers lists it is almost embarrassing. The [November 2014 figures][1] show that 485 of the top 500 systems were running some form of Linux; Windows runs on just one. Things are even more impressive if you look at the numbers of cores involved. Here, Linux is to be found on 22,851,693 of them, while Windows is on just 30,720; what that means is that not only does Linux dominate, it is particularly strong on the bigger systems.
|
||||
|
||||
**Cloud computing**. The Linux Foundation produced an interesting [report][2] last year, which looked at the use of Linux in the cloud by large companies. It found that 75% of them use Linux as their primary platform there, against just 23% that use Windows. It's hard to translate that into market share, since the mix between cloud and non-cloud needs to be factored in; however, given the current popularity of cloud computing, it's safe to say that the use of Linux is high and increasing. Indeed, the same survey found Linux deployments in the cloud have increased from 65% to 79%, while those for Windows have fallen from 45% to 36%. Of course, some may not regard the Linux Foundation as totaly disinterested here, but even allowing for that, and for statistical uncertainties, it's pretty clear which direction things are moving in.
|
||||
|
||||
**Web servers**. Open source has dominated this sector for nearly 20 years - an astonishing record. However, more recently there's been some interesting movement in market share: at one point, Microsoft's IIS managed to overtake Apache in terms of the total number of Web servers. But as Netcraft explains in its most recent [analysis][3], there's more than meets the eye here:
|
||||
|
||||
> This is the second month in a row where there has been a large drop in the total number of websites, giving this month the lowest count since January. As was the case in November, the loss has been concentrated at just a small number of hosting companies, with the ten largest drops accounting for over 52 million hostnames. The active sites and web facing computers metrics were not affected by the loss, with the sites involved being mostly advertising linkfarms, having very little unique content. The majority of these sites were running on Microsoft IIS, causing it to overtake Apache in the July 2014 survey. However the recent losses have resulted in its market share dropping to 29.8%, leaving it now over 10 percentage points behind Apache.
|
||||
|
||||
As that indicates, Microsoft's "surge" was more apparent than real, and largely based on linkfarms with little useful content. Indeed, Netcraft's figures for active sites paints a very different picture: Apache has 50.57% market share, with nginx second on 14.73%; Microsoft IIS limps in with a rather feeble 11.72%. This means that open source has around 65% of the active Web server market - not quite at the supercomputer level, but pretty good.
|
||||
|
||||
**Mobile systems**. Here, the march of open source as the foundation of Android continues. Latest figures show that Android accounted for [83.6%][4] of smartphone shipments in the third quarter of 2014, up from 81.4% in the same quarter the previous year. Apple achieved 12.3%, down from 13.4%. As far as tablets are concerned, Android is following a similar trajectory: for the second quarter of 2014, Android notched up around [75% of global tablet sales][5], while Apple was on 25%.
|
||||
|
||||
**Embedded systems**. Although it's much harder to quantify the market share of Linux in the important embedded system market, but figures from one 2013 study indicated that around [half of planned embedded systems][6] would use it.
|
||||
|
||||
**Internet of Things**. In many ways this is simply another incarnation of embedded systems, with the difference that they are designed to be online, all the time. It's too early to talk of market share, but as I've [discussed][7] recently, AllSeen's open source framework is coming on apace. What's striking by their absence are any credible closed-source rivals; it therefore seems highly likely that the Internet of Things will see supercomputer-like levels of open source adoption.
|
||||
|
||||
Of course, this level of success always begs the question: where do we go from here? Given that open source is approaching saturation levels of success in many sectors, surely the only way is down? In answer to that question, I recommend a thought-provoking essay from 2013 written by Christopher Kelty for the Journal of Peer Production, with the intriguing title of "[There is no free software.][8]" Here's how it begins:
|
||||
|
||||
> Free software does not exist. This is sad for me, since I wrote a whole book about it. But it was also a point I tried to make in my book. Free software—and its doppelganger open source—is constantly becoming. Its existence is not one of stability, permanence, or persistence through time, and this is part of its power.
|
||||
|
||||
In other words, whatever amazing free software 2014 has already brought us, we can be sure that 2015 will be full of yet more of it, as it continues its never-ending evolution.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.computerworlduk.com/blogs/open-enterprise/open-source-has-won-3592314/
|
||||
|
||||
作者:[lyn Moody][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.computerworlduk.com/author/glyn-moody/
|
||||
[1]:http://www.top500.org/statistics/list/
|
||||
[2]:http://www.linuxfoundation.org/publications/linux-foundation/linux-end-user-trends-report-2014
|
||||
[3]:http://news.netcraft.com/archives/2014/12/18/december-2014-web-server-survey.html
|
||||
[4]:http://www.cnet.com/news/android-stays-unbeatable-in-smartphone-market-for-now/
|
||||
[5]:http://timesofindia.indiatimes.com/tech/tech-news/Android-tablet-market-share-hits-70-in-Q2-iPads-slip-to-25-Survey/articleshow/38966512.cms
|
||||
[6]:http://linuxgizmos.com/embedded-developers-prefer-linux-love-android/
|
||||
[7]:http://www.computerworlduk.com/blogs/open-enterprise/allseen-3591023/
|
||||
[8]:http://peerproduction.net/issues/issue-3-free-software-epistemics/debate/there-is-no-free-software/
|
@ -0,0 +1,62 @@
|
||||
How To Install New Fonts In Ubuntu 14.04 and 14.10
|
||||
================================================================================
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/01/fonts.jpg)
|
||||
|
||||
Ubuntu does come with a bunch of fonts installed by default in it. But at times you might not be satisfied with the available lots of fonts. So, what you can do is to **install additional fonts in Ubuntu 14.04**, 14.10 or any other Linux system such as Linux Mint.
|
||||
|
||||
### Step 1: Get fonts ###
|
||||
|
||||
First and foremost, download your choice of fonts. Now you might be thinking from where can you get new fonts. Don’t worry, a simple Google search will provide you with several websites that have new fonts available for free. You can start with [fonts at Lost Type][1]. [Fonts Squirrel][2] is also a good place to download fonts.
|
||||
|
||||
### Step 2: Install new fonts in Ubuntu ###
|
||||
|
||||
The downloaded fonts might be in a zipped file. Extract it. Most of the fonts are either in [TTF][3] (TrueType Fonts) or in [OTF][4] (OpenType Fonts) format. Whichever it may be, just double click on the font file. It will open it in Font Viewer. In here, you can see the option to install the font in top right corner:
|
||||
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/01/Install_New_Fonts_Ubuntu.png)
|
||||
|
||||
You won’t really see anything being installed as you see when installing a software. Couple of seconds later, you’ll see the status has been changed to Installed. No prizes for guessing that the font has been now installed.
|
||||
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/01/Install_New_Fonts_Ubuntu_1.png)
|
||||
|
||||
Once installed, you can see the newly installed fonts in any application that uses fonts such as GIMP, Pinta etc.
|
||||
|
||||
### Step 2: Install several fonts at once in Linux ###
|
||||
|
||||
No, it is not typo. This is still step 2 but just an alternative. The method we saw above to install fonts in Ubuntu is just fine. But there is a little issue with it. What happens when you have like 20 new fonts to install. Installing all these fonts, one by one, by double clicking on them is cumbersome and inconvenient. Don’t you think the same?
|
||||
|
||||
To install several fonts at once in Ubuntu, all you need to do is to create .fonts directory, if it doesn’t exist already, in your Home directory. And extract or copy paste all those TTF or OTF files in this directory.
|
||||
|
||||
Go to your Home directory in File manager. Press Ctrl+H to [show hidden files in Ubuntu][5]. Right click to make a new folder and name it .fonts. That dot at the beginning is important. In Linux, if you put dot ahead of the file name, it hides the file from normal view.
|
||||
|
||||
#### Alternative: ####
|
||||
|
||||
Alternatively, you can install Font Manager application and manage fonts in GUI. To install Font Manager in Ubuntu, open a terminal and use the command below:
|
||||
|
||||
sudo apt-get install font-manager
|
||||
|
||||
Open the Font Manager from Unity Dash. You can see installed fonts and option to install new fonts, remove existing fonts etc here.
|
||||
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/01/Font_Manager_Ubuntu.jpeg)
|
||||
|
||||
To remove Font Manager, use the command below:
|
||||
|
||||
sudo apt-get remove font-manager
|
||||
|
||||
I hope this quick helped you to install fonts in Ubuntu and other Linux systems. Do let me know if you have questions or suggestions.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://itsfoss.com/install-fonts-ubuntu-1404-1410/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://itsfoss.com/author/Abhishek/
|
||||
[1]:http://www.losttype.com/browse/
|
||||
[2]:http://www.fontsquirrel.com/
|
||||
[3]:http://en.wikipedia.org/wiki/TrueType
|
||||
[4]:http://en.wikipedia.org/wiki/OpenType
|
||||
[5]:http://itsfoss.com/hide-folders-and-show-hidden-files-in-ubuntu-beginner-trick/
|
@ -0,0 +1,76 @@
|
||||
How to deduplicate files on Linux with dupeGuru
|
||||
================================================================================
|
||||
Recently, I was given the task to clean up my father's files and folders. What made it difficult was the abnormal amount of duplicate files with incorrect names. By keeping a backup on an external drive, simultaneously editing multiple versions of the same file, or even changing the directory structure, the same file can get copied many times, change names, change locations, and just clog disk space. Hunting down every single one of them can become a problem of gigantic proportions. Hopefully, there exists nice little software that can save your precious hours by finding and removing duplicate files on your system: [dupeGuru][1]. Written in Python, this file deduplication software switched to a GPLv3 license a few hours ago. So time to apply your new year's resolutions and clean up your stuff!
|
||||
|
||||
### Installation of dupeGuru ###
|
||||
|
||||
On Ubuntu, you can add the Hardcoded Software PPA:
|
||||
|
||||
$ sudo apt-add-repository ppa:hsoft/ppa
|
||||
$ sudo apt-get update
|
||||
|
||||
And then install with:
|
||||
|
||||
$ sudo apt-get install dupeguru-se
|
||||
|
||||
On Arch Linux, the package is present in the [AUR][2].
|
||||
|
||||
If you prefer compiling it yourself, the sources are on [GitHub][3].
|
||||
|
||||
### Basic Usage of dupeGuru ###
|
||||
|
||||
DupeGuru is conceived to be fast and safe. Which means that the program is not going to run berserk on your system. It has a very low risk of deleting stuff that you did not intend to delete. However, as we are still talking about file deletion, it is always a good idea to stay vigilant and cautious: a good backup is always necessary.
|
||||
|
||||
Once you took your precautions, you can launch dupeGuru via the command:
|
||||
|
||||
$ dupeguru_se
|
||||
|
||||
You should be greeted by the folder selection screen, where you can add folders to scan for deduplication.
|
||||
|
||||
![](https://farm9.staticflickr.com/8596/16199976251_f78b042fba.jpg)
|
||||
|
||||
Once you selected your directories and launched the scan, dupeGuru will show its results by grouping duplicate files together in a list.
|
||||
|
||||
![](https://farm9.staticflickr.com/8600/16016041367_5ab2834efb_z.jpg)
|
||||
|
||||
Note that by default dupeGuru matches files based on their content, and not their name. To be sure that you do not accidentally delete something important, the match column shows you the accuracy of the matching algorithm. From there, you can select the duplicate files that you want to take action on, and click on "Actions" button to see available actions.
|
||||
|
||||
![](https://farm8.staticflickr.com/7516/16199976361_c8f919b06e_b.jpg)
|
||||
|
||||
The choice of actions is quite extensive. In short, you can delete the duplicates, move them to another location, ignore them, open them, rename them, or even invoke a custom command on them. If you choose to delete a duplicate, you might get as pleasantly surprised as I was by available deletion options.
|
||||
|
||||
![](https://farm8.staticflickr.com/7503/16014366568_54f70e3140.jpg)
|
||||
|
||||
You can not only send the duplicate files to the trash or delete them permanently, but you can also choose to leave a link to the original file (either using a symlink or a hardlink). In oher words, the duplicates will be erased, and a link to the original will be left instead, saving a lot of disk space. This can be particularly useful if you imported those files into a workspace, or have dependencies based on them.
|
||||
|
||||
Another fancy option: you can export the results to a HTML or CSV file. Not really sure why you would do that, but I suppose that it can be useful if you prefer keeping track of duplicates rather than use any of dupeGuru's actions on them.
|
||||
|
||||
Finally, last but not least, the preferences menu will make all your dream about duplicate busting come true.
|
||||
|
||||
![](https://farm8.staticflickr.com/7493/16015755749_a9f343b943_z.jpg)
|
||||
|
||||
There you can select the criterion for the scan, either content based or name based, and a threshold for duplicates to control the number of results. It is also possible to define the custom command that you can select in the actions. Among the myriad of other little options, it is good to notice that by default, dupeGuru ignores files less than 10KB.
|
||||
|
||||
For more information, I suggest that you go check out the [official website][4], which is filled with documention, support forums, and other goodies.
|
||||
|
||||
To conclude, dupeGuru is my go-to software whenever I have to prepare a backup or to free some space. I find it powerful enough for advanced users, and yet intuitive to use for newcomers. Cherry on the cake: dupeGuru is cross platform, which means that you can also use it for your Mac or Windows PC. If you have specific needs, and want to clean up music or image files, there exists two variations: [dupeguru-me][5] and [dupeguru-pe][6], which respectively find duplicate audio tracks and pictures. The main difference from the regular version is that it compares beyond file formats and takes into account specific media meta-data like quality and bit-rate.
|
||||
|
||||
What do you think of dupeGuru? Would you consider using it? Or do you have any alternative deduplication software to suggest? Let us know in the comments.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/dupeguru-deduplicate-files-linux.html
|
||||
|
||||
作者:[Adrien Brochard][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/adrien
|
||||
[1]:http://www.hardcoded.net/dupeguru/
|
||||
[2]:https://aur.archlinux.org/packages/dupeguru-se/
|
||||
[3]:https://github.com/hsoft/dupeguru
|
||||
[4]:http://www.hardcoded.net/dupeguru/
|
||||
[5]:http://www.hardcoded.net/dupeguru_me/
|
||||
[6]:http://www.hardcoded.net/dupeguru_pe/
|
@ -0,0 +1,339 @@
|
||||
Managing Linux server configs with the SaltStack
|
||||
================================================================================
|
||||
![](http://techarena51.com/wp-content/uploads/2015/01/SaltStack+logo+-+black+on+white.png)
|
||||
|
||||
I came across Salt while searching for an alternative to [Puppet][1]. I like puppet, but I am falling in love with Salt :). This maybe a personal opinion but I found Salt easier to configure and get started with as compared to Puppet. Another reason I like Salt is that it let’s you manage your server configurations from the command line, for example:
|
||||
|
||||
To update all your servers with Salt, just run
|
||||
|
||||
salt ‘*’ pkg.upgrade
|
||||
|
||||
**Installing the SaltStack on Linux.**
|
||||
|
||||
Salt is available in the EPEL repo if you are installing it on CentOS 6/7, Pi and Ubuntu linux users can add the Salt Repository from [here][2]. Since Salt is python based you can also use ‘pip’ to install it but you have take care of dependencies like yum-utils and other packages yourself.
|
||||
|
||||
Salt follows the Server-Client model, The Server is known as the master whereas clients are called minions.
|
||||
|
||||
**Installation and Configuration of a Salt Master**
|
||||
|
||||
[root@salt-master~]# yum install salt-master
|
||||
|
||||
Salt configurations files are stored in /etc/salt and /srv/salt. Salt is good to go out of the box, but I would recommend you configure a bit more verbose logging to help your troubleshoot.
|
||||
|
||||
[root@salt-master ~]# vim /etc/salt/master
|
||||
#Default is warning change to the following
|
||||
log_level: debug
|
||||
log_level_logfile: debug
|
||||
|
||||
[root@salt-master ~]# systemctl start salt-master
|
||||
|
||||
**Installation and Configuration of a Salt minion**
|
||||
|
||||
[root@salt-minion~]#yum install salt-minion
|
||||
|
||||
#Add the hostname of your Salt Master
|
||||
[root@salt-minion~]#vim /etc/salt/minion
|
||||
master: salt-master.com
|
||||
#start the minion
|
||||
[root@salt-minion~] systemctl start salt-minion
|
||||
|
||||
On Startup, a minion will generate a cryptographic key and an id. It will then connect to the Salt Master and identify itself. The Salt Master must accept the minion’s key before allowing the minion to download a configuration.
|
||||
|
||||
**Listing and Accepting keys on the Salt Master**
|
||||
|
||||
#List all keys
|
||||
[root@salt-master~] salt-key -L
|
||||
Accepted Keys:
|
||||
Unaccepted Keys:
|
||||
minion.com
|
||||
Rejected Keys:
|
||||
|
||||
#Accept key with id ‘minion.com’
|
||||
[root@salt-master~]salt-key -a minion.com
|
||||
|
||||
[root@salt-master~] salt-key -L
|
||||
Accepted Keys:
|
||||
minion.com
|
||||
Unaccepted Keys:
|
||||
Rejected Keys:
|
||||
|
||||
Once you have accepted a minions keys, you can get information on it immediately using the ‘salt’ command.
|
||||
|
||||
**Salt command line examples**
|
||||
|
||||
#Check if a minion is up and running
|
||||
[root@salt-master~] salt 'minion.com' test.ping
|
||||
minion.com:
|
||||
True
|
||||
# run shell commands on the minion
|
||||
[root@salt-master~]# salt 'minion.com' cmd.run 'ls -l'
|
||||
minion.com:
|
||||
total 2988
|
||||
-rw-r--r--. 1 root root 1024 Jul 31 08:24 1g.img
|
||||
-rw-------. 1 root root 940 Jul 14 15:04 anaconda-ks.cfg
|
||||
-rw-r--r--. 1 root root 1024 Aug 14 17:21 test
|
||||
#install/update a software on all your servers
|
||||
[root@salt-master ~]# salt '*' pkg.install git
|
||||
|
||||
The salt command needs a few components to send information. One of these components is the minion id and another is the function to be called on the minion.
|
||||
In the first example I used the ‘ping’ function of the ‘test’ module to check if the system is up. This function does not perform an actual ping, it just return’s ‘true’ if the minion responds.
|
||||
‘cmd.run’ is used to execute remote commands and ‘pkg’ module contains functions for package management. The full list of builin modules is at the end of this post.
|
||||
|
||||
**Grains example**
|
||||
|
||||
Salt uses an interface called **Grains** to get system information. You can use grains to run commands on systems with particular properties.
|
||||
|
||||
[root@vps4544 ~]# salt -G 'os:Centos' test.ping
|
||||
minion:
|
||||
True
|
||||
|
||||
More grain examples are available at http://docs.saltstack.com/en/latest/topics/targeting/grains.html
|
||||
|
||||
**Package Management via the State File System.**
|
||||
|
||||
In order to automate software configurations you will need to use the state system and create a state file. These files use the YAML format and python dictionaries, lists, strings and numbers for data structure. Reading up on them will help you understand the configurations better.
|
||||
|
||||
**VIM state file example**
|
||||
|
||||
[root@salt-master~]# vim /srv/salt/vim.sls
|
||||
vim-enhanced:
|
||||
pkg.installed
|
||||
/etc/vimrc:
|
||||
file.managed:
|
||||
- source: salt://vimrc
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 644
|
||||
|
||||
|
||||
The first and third line in this file are called state id. They must contain the exact name or path of the package or file to be managed. After the state ids are state and function declaration. ‘pkg’ and file are state declarations whereas ‘installed’ and ‘managed’ are function declarations. Functions accept arguments, user,group,mode and source are all arguments to the function ‘managed’.
|
||||
|
||||
To apply this configuration to a minion move your ‘vimrc’ file to ‘/srv/salt’ and run.
|
||||
|
||||
[root@salt-master~]# salt 'minion.com' state.sls vim
|
||||
minion.com:
|
||||
----------
|
||||
ID: vim-enhanced
|
||||
Function: pkg.installed
|
||||
Result: True
|
||||
Comment: The following packages were installed/updated: vim-enhanced.
|
||||
Started: 09:36:23.438571
|
||||
Duration: 94045.954 ms
|
||||
Changes:
|
||||
----------
|
||||
vim-enhanced:
|
||||
----------
|
||||
new:
|
||||
7.4.160-1.el7
|
||||
old:
|
||||
|
||||
|
||||
Summary
|
||||
------------
|
||||
Succeeded: 1 (changed=1)
|
||||
Failed: 0
|
||||
------------
|
||||
Total states run: 1
|
||||
|
||||
You can also add dependencies to your configurations.
|
||||
|
||||
[root@salt-master~]# vim /srv/salt/ssh.sls
|
||||
openssh-server:
|
||||
pkg.installed
|
||||
|
||||
|
||||
/etc/ssh/sshd_config:
|
||||
file.managed:
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 600
|
||||
- source: salt://ssh/sshd_config
|
||||
|
||||
sshd:
|
||||
service.running:
|
||||
- require:
|
||||
- pkg: openssh-server
|
||||
|
||||
The ‘require’ statement here is a requisite declaration, it creates a dependency between the ‘service’ and ‘pkg’ states. This declaration will first check if the package is installed and then run the service.
|
||||
|
||||
However, I prefer using the ‘watch’ statement as it also checks for file modifications and restarts the service.
|
||||
|
||||
[root@salt-master~]# vim /srv/salt/ssh.sls
|
||||
openssh-server:
|
||||
pkg.installed
|
||||
|
||||
|
||||
/etc/ssh/sshd_config:
|
||||
file.managed:
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 600
|
||||
- source: salt://sshd_config
|
||||
|
||||
sshd:
|
||||
service.running:
|
||||
- watch:
|
||||
- pkg: openssh-server
|
||||
- file: /etc/ssh/sshd_config
|
||||
|
||||
[root@vps4544 ssh]# salt 'minion.com' state.sls ssh
|
||||
seven.leog.in:
|
||||
Changes:
|
||||
----------
|
||||
ID: openssh-server
|
||||
Function: pkg.installed
|
||||
Result: True
|
||||
Comment: Package openssh-server is already installed.
|
||||
Started: 13:01:55.824367
|
||||
Duration: 1.156 ms
|
||||
Changes:
|
||||
----------
|
||||
ID: /etc/ssh/sshd_config
|
||||
Function: file.managed
|
||||
Result: True
|
||||
Comment: File /etc/ssh/sshd_config updated
|
||||
Started: 13:01:55.825731
|
||||
Duration: 334.539 ms
|
||||
Changes:
|
||||
----------
|
||||
diff:
|
||||
---
|
||||
+++
|
||||
@@ -14,7 +14,7 @@
|
||||
# SELinux about this change.
|
||||
# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
|
||||
#
|
||||
-Port 22
|
||||
+Port 422
|
||||
#AddressFamily any
|
||||
#ListenAddress 0.0.0.0
|
||||
#ListenAddress ::
|
||||
|
||||
----------
|
||||
ID: sshd
|
||||
Function: service.running
|
||||
Result: True
|
||||
Comment: Service restarted
|
||||
Started: 13:01:56.473121
|
||||
Duration: 407.214 ms
|
||||
Changes:
|
||||
----------
|
||||
sshd:
|
||||
True
|
||||
|
||||
Summary
|
||||
------------
|
||||
Succeeded: 4 (changed=2)
|
||||
Failed: 0
|
||||
------------
|
||||
Total states run: 4
|
||||
|
||||
Maintaining all config files in single directory can make scaling a complex task, hence you can create sub-directories and add your configuration in them with a init.sls file
|
||||
|
||||
[root@salt-master~]# mkdir /srv/salt/ssh
|
||||
[root@salt-master~]# vim /srv/salt/ssh/init.sls
|
||||
openssh-server:
|
||||
pkg.installed
|
||||
|
||||
|
||||
/etc/ssh/sshd_config:
|
||||
file.managed:
|
||||
- user: root
|
||||
- group: root
|
||||
- mode: 600
|
||||
- source: salt://ssh/sshd_config
|
||||
|
||||
sshd:
|
||||
service.running:
|
||||
- watch:
|
||||
- pkg: openssh-server
|
||||
- file: /etc/ssh/sshd_config
|
||||
|
||||
[root@vps4544 ssh]# cp /etc/ssh/sshd_config /srv/salt/ssh/
|
||||
[root@vps4544 ssh]# salt 'minion.com' state.sls ssh
|
||||
|
||||
**Top File and Environments.**
|
||||
|
||||
A Top file (top.sls) is where you define your environments. A top file allows you to map minions to packages. The default environment is ‘base’. You need to define which packages will be installed on which server under the base environment.
|
||||
|
||||
If there are multiple environments and more than one definitions for a particular minion is used then by default the base environment will supersede the others.
|
||||
|
||||
To define an environment you need to add it to the ‘file_roots’ directive in the master configuration file.
|
||||
|
||||
[root@salt-master ~]# vim /etc/salt/master
|
||||
file_roots:
|
||||
base:
|
||||
- /srv/salt
|
||||
dev:
|
||||
- /srv/salt/dev
|
||||
|
||||
Now add a top.sls file in /srv/salt
|
||||
|
||||
[root@salt-master ~]# vim /srv/salt/top.sls
|
||||
base:
|
||||
'*':
|
||||
- vim
|
||||
'minion.com':
|
||||
- ssh
|
||||
|
||||
Apply the top file configuration with
|
||||
|
||||
[root@salt-master~]# salt '*' state.highstate
|
||||
minion.com:
|
||||
----------
|
||||
ID: vim-enhanced
|
||||
Function: pkg.installed
|
||||
Result: True
|
||||
Comment: Package vim-enhanced is already installed.
|
||||
Started: 13:10:55
|
||||
Duration: 1678.779 ms
|
||||
Changes:
|
||||
----------
|
||||
ID: openssh-server
|
||||
Function: pkg.installed
|
||||
Result: True
|
||||
Comment: Package openssh-server is already installed.
|
||||
Started: 13:10:55.
|
||||
Duration: 2.156 ms
|
||||
|
||||
The minion will download the top file and search for it’s configuration. It will also apply the configuration for all minions.
|
||||
|
||||
This is just a brief introduction to Salt, for in depth understanding you can go through the links below and if you are already using Salt and have any recommendations do let me know.
|
||||
|
||||
Update: [Foreman][3] has support for salt via [plugins][4].
|
||||
|
||||
Read
|
||||
|
||||
- http://docs.saltstack.com/en/latest/ref/states/top.html#how-top-files-are-compiled
|
||||
- http://docs.saltstack.com/en/latest/topics/tutorials/states_pt1.html
|
||||
- http://docs.saltstack.com/en/latest/ref/states/highstate.html#state-declaration
|
||||
|
||||
Grains
|
||||
|
||||
- http://docs.saltstack.com/en/latest/topics/targeting/grains.html
|
||||
|
||||
List of Salt Modules
|
||||
|
||||
Good comparison of Salt and puppet
|
||||
|
||||
- https://mywushublog.com/2013/03/configuration-management-with-salt-stack/
|
||||
|
||||
Full list of builtin execution modules
|
||||
|
||||
- http://docs.saltstack.com/en/latest/ref/modules/all/
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://techarena51.com/index.php/getting-started-with-saltstack/
|
||||
|
||||
作者:[Leo G][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://techarena51.com/
|
||||
[1]:http://techarena51.com/index.php/a-simple-way-to-install-and-configure-a-puppet-server-on-linux/
|
||||
[2]:http://docs.saltstack.com/en/latest/topics/installation/index.html
|
||||
[3]:http://techarena51.com/index.php/using-foreman-opensource-frontend-puppet/
|
||||
[4]:https://github.com/theforeman/foreman_salt/wiki
|
Loading…
Reference in New Issue
Block a user