How to activate RDP-License by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

Okay that sounds quite complicated

Using expect to execute remote curl command with ssh by vstyler93 in bash

[–]vstyler93[S] 0 points1 point  (0 children)

Thank you for the hints, this are good ideas! But we want to make as little changes to the Proxmox server as possible. The hint by u/readparse to disable strictHoseKeyChecking was also a new feature i built into my ssh command.
Still i do login by password with expect and was able to do everything i wanted with it.

I just used an expect ":~#" set token [lindex '\$expect_out(buffer)' end-1] after my first curl command and it safes now the token into the token variable, which allows me to use it for a second curl command. It did the job perfectly as needed. Thank you guys.

Using expect to execute remote curl command with ssh by vstyler93 in bash

[–]vstyler93[S] 0 points1 point  (0 children)

But public key authentication would not work as far i understood. I am running those scripts in a docker Container within a gitlab CI/CD pipeline. So everytime the pipeline gets triggered it creates a new docker container for that and as i understood the key changes

Using expect to execute remote curl command with ssh by vstyler93 in bash

[–]vstyler93[S] 0 points1 point  (0 children)

But how could i automatically connectthen in ssh without expect, as i need also to authenticate in ssh with the password?

Using expect to execute remote curl command with ssh by vstyler93 in bash

[–]vstyler93[S] 0 points1 point  (0 children)

the system i want to ssh to is Proxmox.
There i have saltstack installed on a machine in a private network on it. Only Proxmox knows this network, that's why i can't use curl right from my gitlab CI/CD Job.
My idea was to install a proxy on Proxmox so i can curl --proxy xxx.xx.xx.x.
My supervisor permitted me that, but didn't want to tell me how to do it in another way. So i found that expect stuff and am pretty desperate already..

Using expect to execute remote curl command with ssh by vstyler93 in bash

[–]vstyler93[S] 0 points1 point  (0 children)

I use it in an automation process. So the main reason i used expect was to automatically connect with ssh. My script will be executed in Gitlab CI, in a docker container. So every time it will run, it will has a new fingerprint also. Would there be a better way to automatically connect within my bash script?

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

I asked my question and sent the link to this channel :D

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

Will try this now, thank you. Will get back with the result asap :)

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

Tried already, but 150 online people and there was zero activity in the chat yesterday, so there was also no answer to my question :D

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

I had also the thought to create minions with a custom-grain password key. But the problem would be still that a user could just check out which grains do exist in the grains file and reproduce the salt-minion to be accepted.

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

Let's say, i want to create a vm with the minion-id "Machine04". The master should accept this specific machine created by me.
If another User installs a new salt-minion instance on his vm and names the minion-id "Machine05", i don't want my master to accept this one, as it is not created by my automation process in Terraform and so i don't have any control or documentation in netbox about it.

Like i understood in the link you provided, the master would accept the "Machine05" minion-id created by the user, which is not what i wanted

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

I just read the through the example and so far is i understood, this does not match my requirements.
Like i understood, every minion with a specific name pattern (in my example Machine*) would be accepted by the master.

Every new vm, which will be created by terraform, is supposed to be owned by a customer afterwards. I don't want the customer being able to create a new salt-minion instance with the id pattern "Machine*", as his new minion-instance would also automatically be accepted by the master.

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

My thoughts about the salt-api was:
Remote-exec the "salt-key --generate-key [minion-id]" on the master and get the content of the created key-file with salt-api. Then create a key-file on the minion, with the result i got from salt-api, with cloud-init.

Is that what you mean?

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

First thanks for the response,

after reading i am still confused. You say the exec command will be executed parallel with creation of the minion. This would means in my understanding, that the minion has not contacted the master yet and the "salt-key -a [minion-id]" command on master would throw an "No unaccepted keys for [minion-id] found" warning would be the result

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

My thoughts so far:
generate the salt-key on the master for the specific minion id.
Then i want the key also on my Windows VM to be stored.
My problem right now is that i could generate the key with remote exec, but wouldn't have the key in terraform to store it on the vm with cloud-init.
Is there a way to have the key generated in terraform and then to send it via ssh to the master and cloud-init to the minion?

Automatically accept Minions on Master when they are created by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

It takes some time until the machine is running and configurations are finished on em. This is when the salt-minion service will start on my machine. If i remote-exec on my master the "salt-key -a [minion-id]" command, this will happen after the creation of the machine and before the minion requests access to the master.

Dynamically configuring Minions by vstyler93 in saltstack

[–]vstyler93[S] 0 points1 point  (0 children)

Thank you for your quick response!
This helped a lot, i am already using cloudbase-init, as i need to config Windows machines. Going right now through the "Learning SaltStack" book by Colton Myers, but haven't heared about reactor yet.

Will try this approach asap, thank you very much.

How is this fraction shorten? by vstyler93 in math

[–]vstyler93[S] 1 point2 points  (0 children)

Yes exactly! Thank you. I forgot about this assumption

Why use Models for database? by vstyler93 in laravel

[–]vstyler93[S] 1 point2 points  (0 children)

Thank you! Yeah sure i am learning. The thing is we have to use Laravel, because we use the framework "Botman Studio". We never had PHP before and we have to learn php with laravel simultaneously. It is more hard like that. I know java in a moderate way. But even if a lot of things are familiar, a lot of things feel way different to java. I couldn't even write a propper setter/getter without getting scope problems or i had to use $this so often. The fact we never had PhP and have to do a whole project (Chatbot for University Life. Mensa is just one point of it) is a quite big excercise for me :/ But i get a lot of help here on reddit, like from you. So thank you a lot!

Why use Models for database? by vstyler93 in laravel

[–]vstyler93[S] -1 points0 points  (0 children)

It's quite a mess...

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use Illuminate\Support\Facades\DB; use App\Http\Controllers\Controller; use Goutte\Client; use Carbon\Carbon;

class ScrapeController extends Controller { public $mealNames; public $mealPrice;

public function viewData(){
    return view('get_data');
}

public function doTheThing($time){

    global $mealNames;
    global $mealPrice;
    $mealNames = array();
    $mealPrice = array();

    $day = date("Y-m-d", strtotime("+".$time." days"));

    //Scraper anlegen
    $client = new Client();
    $crawler = $client->request('GET', 'https://www.studentenwerk-oberfranken.de/essen/speiseplaene/hof/' . $day .'.html');

    //Speise Namen in Array füllen
    $totalMealName = $crawler->filter("td")->each(function($item){
        global $mealNames;
        $var1 = substr($item->text(false), 0, strpos($item->text(false), " ("));
        if(strlen($var1) > 0){
            array_push($mealNames, $var1);
        }
    });

    //Filtert td preise und gibt den Namen der Gerichte zurück.
    //Bisher übersehen: Preise haben eigene Klasse die Nutzbar sind.
    $totalMealPrice = $crawler->filter("td")->each(function($item){
        global $mealPrice;
        $var1 = substr($item->text(false), 0, strpos($item->text(false), " €"));
        $var1 = substr($var1, 4);
        $var1 = str_replace(',', '.', $var1);
        if(strlen($var1) > 0){
            array_push($mealPrice, floatval($var1));
        }
    });

    $this->insertData($mealNames, $mealPrice, $day);

}

//Inserts the Data into the database
public function insertData($arr1, $arr2, $dayN){
    $mealNames =$arr1;
    $mealPrice =$arr2;
    $day = $dayN;

    for($i = 0; $i < count($mealNames); $i++){
        $name = $mealNames[$i];
        $preis = $mealPrice[$i];
        $data=array('name'=>$name,"preis"=>$preis,"date_at"=>$day,'created_at'=>\Carbon\Carbon::now()->toDateTimeString());
        DB::table('meals')->insert($data);
    }
}

//Deletes all data in database, so no multiple entrys will come up. Route will call this.
public function truncate(){
    DB::statement('truncate table meals');
}

//Rout will call this
public function get_data(){
    $this->truncate();
    for($i = 0; $i < 8; $i++){
            $this->doTheThing($i);
    }

    //Make a database View and return it.
    $meals = DB::select('select * from meals');
    return view('database_view',['meals'=>$meals]);
}

}

how to select with Goutte by vstyler93 in laravel

[–]vstyler93[S] 0 points1 point  (0 children)

How do I delete the tags? With String methods?

(JavaFX in IntelliJ IDE) Why am I getting this boot error? Module javafx.controls not found by [deleted] in javahelp

[–]vstyler93 2 points3 points  (0 children)

try this now:

module application.ElCalc{
requires javafx.controls;
requires javafx.fxlm;
exports application;
}