34

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. ...


23

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

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 ...


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

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

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


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

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

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

Terraform is awesome for setting everything up. I like it less for the actual configuration. After Terraform runs and sets everyhting up (ec2 security groups/instances etc,.) we run Ansible to configure additional users. I recommend leaving AWS default user (ec2user, ubuntu) if you're using SSH Keys. Add to your 'authorized keys' all the public keys for ...


1

I found a way to set environmental variables globally from a file! I'm using envInject for loading variables from a file. For example, lets say I have a file that is called "versionNumber.txt" and that it's created during the build process. Maybe I update it in every build, or any other way. then I create a prosFile that can be identified by the envInject, ...


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

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 ...


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/$...


1

I cannot say this is a the best answer so I do hope someone can provide a better clarification. It seems the default shell for sh() in Jenkins is Bourne. By updating the sh() with the correct shell this allows the below usage: sh'''#!/bin/bash IFS='/' branch=($1) # Use it. ''' This doesn't resolve the the redirection error. Also I would ...


1

Well, to begin with, one of the key concepts behind the CaaS/PaaS/FaaS services is the offloading of the OS maintenance burden :) So it shouldn't even matter what version (or even what OS! - it could even be a proprietary one) the provider runs under the hood as long as the CaaS/PaaS/FaaS service performs according to the respective SLAs. Which is, in a way,...


1

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


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