@komar source: source filename [arguments]
Execute commands from a file in the current shell.
Read and execute commands from FILENAME in the current shell. The
entries in $PATH are used to find the directory containing FILENAME.
If any ARGUMENTS are supplied, they become the positional parameters
when FILENAME is executed.
Exit Status:
Returns the status of the last command executed in FILENAME; fails if
FILENAME cannot be read.
@komar Shell Function Definitions
A shell function is an object that is called like a simple
command and executes a compound command with a new set of
positional parameters. Shell functions are declared as
follows:
name () compound-command [redirection]
function name [()] compound-command [redirection]
This defines a function named name. The reserved word
function is optional. If the function reserved word is
supplied, the parentheses are optional. The body of the
function is the compound command compound-command (see
Compound Commands above). That command is usually a list
of commands between { and }, but may be any command
listed under Compound Commands above, with one exception:
If the function reserved word is used, but the
parentheses are not supplied, the braces are required.
compound-command is executed whenever name is specified
as the name of a simple command. When in posix mode,
name may not be the name of one of the POSIX special
builtins. Any redirections (see REDIRECTION below)
specified when a function is defined are performed when
the function is executed. The exit status of a function
definition is zero unless a syntax error occurs or a
readonly function with the same name already exists.
When executed, the exit status of a function is the exit
status of the last command executed in the body. (See
FUNCTIONS below.)
@enterprize Да я несколько раз пытался че-нибудь из этого освоить. Каждый раз охуевал от оверхеда — имеются в виду трудозатраты — бросал это дело и писал бош-скрепт.
@enterprize Ну то есть, блять, я вообще не понимаю, как этой хуйней что-то там себе упростить можно.
Разве что человеку, который прыщей вообще ни разу не видел, и копипастит рецептики со стэковерфлоу.
@komar Ну хз, если не дрочить на туториалы латентных оопшников, то с ансиблом жить можно.
Там, если что, разводить тысячу ролей и ямлов с инклюдами вообще необязательно, можно нарисовать один небольшой файл про «хочу, чтобы был пакет X, конфиг Y из Jinja-шаблона, строка S в файле Z и сервис X под юзером Ы, перезапускаемый, когда указанные файлики точно меняются» и применять от трёх до трёхсот раз в день по настроению. Никакого кровавого тырпрайза, примитивная автоматизация примитивной рутины, читать тысячу страниц имени O'Reilly не надо, да и lineinfile поприятнее будет, чем каждый раз на sed&&mv переизобретать велосипед.
А вот если нужно состояние посложнее, то все инструменты быстро начинают обсираться. Впрочем, если у тебя два сервера и тебе не нужны ни идемпотентность, ни хендлеры, то тебе хватит и шелл-скриптов. Один хуй через год или обновлять всё реинсталлом и всё переписывать, или вас купят, или вы обанкротитесь к хуям.
@enterprize Ну и у меня с десятка два серверов, и я не банкрочусь уже лет пять.
А чудо-поебень для автоматизации нужна потому, что мне лень вспоминать, какие команды в баше набирать.