m346/KN03/cloud-init-web.yaml

48 lines
1.5 KiB
YAML
Raw Normal View History

2023-09-02 15:23:30 +02:00
#cloud-config
users:
- name: ubuntu
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users, admin
home: /home/ubuntu
shell: /bin/bash
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC0WGP1EZykEtv5YGC9nMiPFW3U3DmZNzKFO5nEu6uozEHh4jLZzPNHSrfFTuQ2GnRDSt+XbOtTLdcj26+iPNiFoFha42aCIzYjt6V8Z+SQ9pzF4jPPzxwXfDdkEWylgoNnZ+4MG1lNFqa8aO7F62tX0Yj5khjC0Bs7Mb2cHLx1XZaxJV6qSaulDuBbLYe8QUZXkMc7wmob3PM0kflfolR3LE7LResIHWa4j4FL6r5cQmFlDU2BDPpKMFMGUfRSFiUtaWBNXFOWHQBC2+uKmuMPYP4vJC9sBgqMvPN/X2KyemqdMvdKXnCfrzadHuSSJYEzD64Cve5Zl9yVvY4AqyBD aws-key
ssh_pwauth: false
disable_root: false
package_update: true
packages:
- apache2
- curl
- wget
- php
- libapache2-mod-php
- php-mysqli
- adminer
write_files:
- content: |
<?php phpinfo(); ?>
path: /var/www/html/info.php
permissions: '0644'
- content: |
<?php
$servername = "172.31.63.80";
$username = "admin";
$password = "password";
$dbname = "mysql";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "select Host, User from mysql.user;";
$result = $conn->query($sql);
while($row = $result->fetch_assoc()){
echo($row["Host"] . " / " . $row["User"] . "<br />");
}
?>
path: /var/www/html/db.php
permissions: '0644'
runcmd:
- sudo a2enconf adminer
- sudo systemctl restart apache2