35

I never used Ansible but since a few weeks, I try to figure out what good Ansible could be in comparison with shell scrips–Which proves, at least in my case, that the haunting ad-campaigns they run are effective! After many unsuccessful attempts–which proves how their documentation fail at answering one of the most obvious question–I think I finally got it. ...


24

When you put it this way, even if Ansible has some inherent advantages, the benefits of using familiar tools (in this case shell scripting) must be outweighed. I don't think there's a clear cut answer to that. If the team can achieve the things Ansible offers with shell: Declarative, idempotent configuration management Access to re-usable snippets (i.e. ...


13

The above answer covers part of it but misses one of the important elements: convergent design. I wrote some words a while ago about this in the context of Chef at https://coderanger.net/thinking/ but the short version is that a bash script is a set of instructions, while an Ansible playbook (or Chef recipe, Salt state, etc) is a description of desired state....


5

The only way to do it with cqlsh is wrap binary file into CSV file and run cqlsh --some_args -e 'COPY table_name FROM binary_wrapped.csv', but in order to do so you have to generate a new primary key to use in CSV-file. IMO: Since cqlsh is a wrapper around python client, your ops should just write simple python script for this operation, it would be much ...


3

The issue is that prereqs-ubuntu.sh uses bash to install the npm. While the RUN directive uses sh to run the commands. Where is the npm installed root@2cd4a6af90f4:/app# type npm npm is /root/.nvm/versions/node/v8.16.0/bin/npm The PATH for the RUN directive # echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin


3

There is no "right" or "wrong". If the commands work when you type them in, then they work, and we won't keep you from doing it. Everything else is opinion. Sure, there are some best practices, for example some people find it unwise to directly fetch scripts from a public (3rd party) website and execute those locally without having a look inside first. It ...


3

The reason; having a more a version-agnostic and more backward-compatible directive in my server-environment-establishment script, to change the values of these two variables. If you're trying to configure a server, you should use a configuration management system (Ansible, Puppet, Chef, Salt) or bake images for immutable infrastructure; trying to hack ...


3

It's 2019 and I've just spent a few days on an ansible learning curve and here is the absolute truth: Ansible isn't worth the trouble. it's not finished, it doesn't run on windows and the combination of YAML config and misleading error messages will make your eyes bleed. It seems almost deliberately terrible and I mean that seriously. It's clearly the ...


3

One thing worth noting that you will have less issues in running your ansible playbooks on remote hosts too. As it's the main reason for running ansible. When you are using shell scripting you still need to have a way to script the scp'ing to the remote host.


3

I do not believe that there is a way to set this as a global policy. However, there is a simple command you can run that will "prune" or remove your unused images. You will want to use docker image prune --filter [options] to achieve this. Check out the official documentation for information on how to best filter. As a best practice you should be tagging ...


3

I am looking for a way for our members to submit scripts without fussing too much about format or folder structure. It sounds like you need some combination of testing and linting, perhaps with a few utility scripts to organise and gate content from landing in the repo. The "Vetting process" you mention sounds to me exactly like "tests need ...


2

Please provide more information about the method and the result as Husyn asked, it may be more suited to programming SO if it is PHP related. Anyway: <?php should be present at the start of any PHP script. If a PHP error occurs, you might not see it without error reporting enabled. If the actual shell command fails or outputs warnings, you won't see it ...


2

Negation to the rescue: sed -i "s/server.address=[^\ ].*\ /server.address=${SERVER_ADDRESS} /g" This is telling to search zero or more characters (.*) NOT matching whitespace ([^\ ]) up to the first whitespace. A good pattern is not to use real values to be replaced (10.111.11.11:3197) but to use a mark like ###SERVER_ADDRESS###. If something goes wrong ...


2

Look this: #!/bin/bash #Get servers list set -f string=$DEPLOY_SERVER array=(${string//,/ }) for i in "${!array[@]}"do echo "Deploy project on server ${array[i]}" done I found this link


2

You could try to use docker compose and the docker compose "extra_hosts" tag, as described on the docker compose specification at https://docs.docker.com/compose/compose-file/. extra_hosts Add hostname mappings. Use the same values as the docker client --add-host parameter. extra_hosts: "somehost:162.242.195.82" "otherhost:50.31.209....


2

There seems to be some syntax issues and also I would suggest to use bash instead if using sh shell. Try the below code and see if this works properly. (EDIT - Put shebang on first line to accept as answer) sh label: 'Stop and Remove Old Docker Container', script: '''#!/usr/bin/env bash docker ps -a echo $APP_CONTAINER_NAME ...


2

I found out how to do it without pipeline. It only has to do with command line script: start "" C:\MyApp\MyApp.exe >> text.txt This call is asynchronous (i.e., the command line won't wait for MyApp.exe to return). If you want it to wait, you can use the /w flag, like this: start /w "" C:\MyApp\MyApp.exe >> text.txt


2

I'd recommend a temporary container for this. It will work on just about any version of docker, and supports named volumes with non-default settings, e.g. that store data on remote systems (e.g. NFS) or modify the bind mound settings to use another folder. A simple example is: $ docker container run --rm -v "${volume_name}:/volume" -w /volume busybox df -P ...


2

Not in pure Docker Compose. If you have a plain-text templating engine you like (Mustache, Jinja, m4, ...) you can ask it to do this for you. You tagged this as shell-script, and Compose can take the YAML configuration on stdin, so in principle one option is to write a shell script, and then pipe that into docker-compose: #!/bin/sh buildComposeYaml() { ...


2

Using docker-compose version 3.3 extensions and with the long variants for ports & volumes: version: '3.3' services: s1: &s build: . ports: - published: 5001 target: 9000 volumes: - source: ../www1 target: /var/www s2: <<: *s ports: - published: 5002 volumes: - source: ../www2 s3: &...


2

Have you considered running this on AWS Lambda. It will probably forever free under free tier. There may be a couple of cents cost on API Gateway. Otherwise you can rent outdated servers for cents per month, but I am unsure what the best search term is for that. Finally, email addresses are free to generate and you can invest the time to set up a fresh AWS ...


1

For executing the command in the Jenkins Freestyle Job. #!/bin/bash du -sh /bbhome/shared/data/repositories/* |sort -h |tail -20 | while IFS= read -r line;do DIR=`echo $line | awk '{print$2}'` Rep=`cat $DIR/repository-config |grep 'project\|repo' | tr '\n' ' '` Size=`echo $line | awk '{print $1}' ` echo $Size $Rep done For ...


1

You can specify the script in the "execute shell" step of the build. Where it gets executed will depend on what labels the job needs, and which nodes those labels are associated with. It sounds like you want to execute this script on an agent. As long as the agent is available, you can request it via a label in the job configuration. It's a bit difficult to ...


1

You can do this using perl For Example perl -pi -e "s/server.address=localhost/server.address=${SERVER_ADDRESS}/g" file_path This command change server address value localhost to vaariable value. Hope this works


1

If you are using Gitlab merely as a source code repository, and you are triggering the jobs when there are changes to the repository. The Jenkins Gitlab plugin documentations states: This plugin is a build trigger that allows GitLab to trigger Jenkins builds when code is pushed or a merge request is created. Configuration done on a per-job basis. So, ...


1

PHP has supported conf.d configuration subdirectories for ages now (cf. PHP_INI_SCAN_DIR in its documentation, this stuff is as old as PHP 5 basically) - allowing you to simply add a small file containing just the snippet of config you need in there, and as long as you make sure it's named so that it's ordered in a way it overrides the defaults, you're done. ...


1

You could extract the common, shareable portions of the scripts which you'd package as either standalone scripts or libraries (depending on the scripting language you use and/or preferences), placed in a shared location (of course, backed by their own repository). Then, in the scripts from your code repositories you'd replace the extracted portions with ...


1

You should regenerate this file from a template using your configuration management system of choice. You could also write a shell script that uses a heredoc to do the same thing. But since we're in DevOps-land you really should be using your configuration management system for these things.


1

You can use below. [user@xyz ~]$ hh='mysql.username=USERNAME';echo $hh | awk -F"=" '{OFS=FS}{ $2="Mango"; print }' mysql.username=Mango


1

You can obtain old parameters from the properties file before using sed, e.g. # get old parameters $ export oldUsername=$(grep mysql.username $FILE | cut -d'=' -f2) $ export oldPass=$(grep mysql.pass $FILE | cut -d'=' -f2) # set new parameters $ export newUsername=NEW_USERNAME $ export newPass=NEW_PASS # change parameters $ sed -i "s/$oldUsername/$...


Only top voted, non community-wiki answers of a minimum length are eligible