Esteemed Collegues, I have created a Playbook to replcae the Entry in a file using a lineinfile module, while i tried running it run and replace in entry on the one host while not on the another host, i don't understand why? as it doesn't report any error even on the debug mode. Do i need to have some another regex pattern.
---
- name: Playbook to replace the line in file
hosts: all
remote_user: root
gather_facts: False
serial: 4
tasks:
- name: replace line
lineinfile:
dest: /tmp/test_master
state: present
regexp: '^passwd: files ldap' # line to be replaced
line: 'passwd_compat: ldap' # new line which is replace existing , the one above
backrefs: yes
backup: yes
register: nss
- name: replace line
debug: var=nss
My Hostvar Inventory File:
# test_regex_hosts
[hosts]
Dev-mauj
Dev-pranjala
[hosts:vars]
ansible_ssh_user=root
ansible_ssh_private_key_file=/Dev/ansibleSpotin
Destination File contents:
$ cat /tmp/test_master
#
# nsswitch.conf
#
passwd: files ldap
shadow: files ldap
group: files ldap
hosts: files dns
bootparams: files
ethers: files
netmasks: files ldap
networks: files ldap
protocols: files ldap
rpc: files ldap
services: files ldap
netgroup: files ldap
publickey: files ldap
automount: files ldap
printers: user files ldap
sudoers: ldap
aliases: files ldap
Note: ansible 2.4
I got the Play working by the help of google Ansible group's hint. while using the regexp You need to account for white space. In this case after the string passwd there is a litral space which needs to be covered with .* so the regex can be expanded correctly! Below is the catch which works prefectly now!
regexp: '^passwd:.*files ldap'
Related
I have an OpenShift PHP pod running an application and I need to authenticate a user account against an Active Directory server. The LDAP bind is failing with a certificate error
LDAP Error (authenticateUser), Cannot bind to LDAP : error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed (unable to get local issuer certificate) - ldap_bind failed
It was suggested I need to install the AD servers certificate into the pod. The certificate has now been copied into the Git repository. I thought I may be able to use a Life Cycle Hook to install the certificate into /etc/openldap/certs/
rollingParams:
post:
execNewPod:
command:
- /bin/sh
- '-c'
- >-
/usr/bin/cp
/opt/app-root/src/certificates/certificate.pem
/etc/openldap/certs/
containerName: application
failurePolicy: Ignore
However there is a permissions error - I assume that the deployment is not running as root so the directory is not accessible.
/usr/bin/cp: cannot create regular file '/etc/openldap/certs/certificate.pem': Permission denied
Is it possible to copy this certificate using the DeploymentConfig or is there a better way to do this?
I managed to resolve this. You need to add the ldap.conf and the certificate to ConfigMaps.
oc create configmap configmap_name --from-file=filenam=path and filename
Then you need to mount the ConfigMaps:
volumeMounts:
- mountPath: /etc/openldap/ldap.conf
name: openldap-ad-config-volume
subPath: ldap.conf
- mountPath: /etc/openldap/certs/certificate.pem
name: ad-certificate-volume
subPath: certificate.pem
volumes:
- configMap:
defaultMode: 292
name: openldap-ad-config
name: openldap-ad-config-volume
- configMap:
defaultMode: 292
name: ad-certificate
name: ad-certificate-volume
Property subPath is used so that the rest of the contents of the directory are not excluded as mounting normally mounts the whole of the directory. Property defaultMode is used otherwise the files will be world read/write.
I am working on the docker environment, and executed docker exec -it mycassandra cqlsh. Then, I am inserting the data, and it is occurring the following error:
WriteTimeout - Error from server: code=1100
By this, it tells me that I need to find out the cassandra.yaml document and amend the write-time, but I can not find that on my MAC.
Could you tell me how can I find it and how to amend the document?
Thanks.
for those who have installed it as brew install cassandra, yaml file will located in usr/local/etc/cassandra
If you are running the official cassandra image then cassandra.yaml may be found at /etc/cassandra/cassandra.yaml in the container. If you want to create a custom cassandra.yaml file then you may try to overwrite it in your Dockerfile or docker-compose.yml file. For example, in my docker-compose.yml file I have something like:
services:
cassandra:
image: cassandra:3.11.4
volumes:
- ./cassandra.yaml:/etc/cassandra/cassandra.yaml
which causes the cassandra.yaml file in the container to be overwritten by my local cassandra.yaml.
I hope this helps.
From the provided example, it seems that the database is executed from inside a container. So the cassandra.yaml that you're looking for will be created on the fly when the container is started up, based on the configuration that you provided.
We have set Cassandra Containers with Kubernetes, and execute them in docker, based on the instructions found here, and been able to modify the settings of the cassandra.yaml file in the configuration of the statefulset, updating the variables in env for the spec of the container.
For example, to modify the seeds list, the cluster name, and the rack of the C* cluster named c-test-qa:
apiVersion: apps/v1
kind: StatefulSet
...
spec:
serviceName: c-test-qa
replicas: 1
selector:
matchLabels:
app: c-test-qa
template:
metadata:
labels:
app: c-test-qa
spec:
containers:
- name: c-test-qa
image: cassandra:3.11
imagePullPolicy: IfNotPresent
...
env:
- name: CASSANDRA_SEEDS
value: c-test-qa-0.c-test-qa.qa.svc.cluster.local
- name: CASSANDRA_CLUSTER_NAME
value: "testqa"
- name: CASSANDRA_RACK
value: "DC1"
- name: CASSANDRA_RACK
value: "CustomRack1"
...
On MacOS :
It will be found in either of the below locations:
Cassandra package installations: /etc/cassandra
Cassandra tarball installations: install_location/conf
DataStax Enterprise package installations: /etc/dse/cassandra
DataStax Enterprise tarball installations: install_location/resources/cassandra/conf
---
- name: install apache2, sqlite3, git pn remote server
hosts: host01
sudo: yes
tasks:
- name: Install list of packages
action: apt pkg={{item}} state=installed
with_items:
- apache2
- sqlite3
- git
INVENTORY FILE NAME: myhosts
$cat myhosts
[group1]
host01 ansible_ssh_user=ubuntu
COMMAND USED: ansible-playbook -i myhosts test.yml
ERROR is below one, I don't know what went wrong someone help me in this.
ERROR: Syntax Error while loading YAML script, test.yml
Note: The error may actually appear before this position: line 7, column 12
- name: Install list of packages
action: apt pkg={{item}} state=installed
^
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
Should be written as:
with_items:
- "{{ foo }}"
Indendation seems wrong at it should be two spaces character by level so try with something like this regarding indentation issue.
---
- name: install apache2, sqlite3, git pn remote server
hosts: host01
sudo: yes
tasks:
- name: Install list of packages
action: apt pkg={{item}} state=installed
with_items:
- apache2
- sqlite3
- git
---
- hosts: all
become: yes
name: install apache2, sqlite3, git pn remote server
tasks:
- name: Install list of packages
action: apt pkg={{item}} state=installed
with_items:
- apache2
- sqlite3
- git
this works for me...
Given command as
---
- name: install apache2, sqlite3, git pn remote server
hosts: host01
become: yes
tasks:
- name: Install list of packages
action: apt pkg={{item}} state=installed
with_items:
- apache2
- sqlite3
- git
below error
ansible-playbook -i myhosts test.yml -b
PLAY [install apache2, sqlite3, git pn remote server] *************************
GATHERING FACTS ***************************************************************
fatal: [host01] => SSH Error: ssh: connect to host host01 port 22: Connection refused
while connecting to 172.17.3.177:22
It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.
TASK: [Install list of packages] **********************************************
FATAL: no hosts matched or all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit #/home/scrapbook/test.retry
host01 : ok=0 changed=0 unreachable=1 failed=0
I am trying to follow an e-commerce tutorial where I have to create the connection with the database. I am on windows 7 with xampp v3.2.
So I use this : php bin/console generate:doctrine:entity
which gives me this error :
SQLSTATE[HY000] [2002] no connection could be made because the target
machine actively refused it
I closed xampp and I still had the same error. So I understand it comes from the configuration; somehow my shell doesn't communicate with my sql server from xampp.
here is my parameters.yml :
# This file is auto-generated during the composer install
parameters:
database_host: localhost
database_port: 3306
database_name: market
database_user: sebastian
database_password:
mailer_transport: smtp
mailer_host: localhost
mailer_user: null
mailer_password: null
secret:
and here my config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
- { resource: "#EcommerceBundle/Resources/config/services.yml" }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
framework:
#esi: ~
#translator: { fallbacks: ["%locale%"] }
secret: "%secret%"
router:
resource: "%kernel.root_dir%/config/routing.yml"
strict_requirements: ~
form: ~
csrf_protection: ~
validation: { enable_annotations: true }
#serializer: { enable_annotations: true }
templating:
engines: ['twig']
default_locale: "%locale%"
trusted_hosts: ~
trusted_proxies: ~
session:
# http://symfony.com/doc/current/reference/configuration/framework.html#handler-id
handler_id: session.handler.native_file
save_path: "%kernel.root_dir%/../var/sessions/%kernel.environment%"
fragments: ~
http_method_override: true
assets: ~
# Twig Configuration
twig:
debug: "%kernel.debug%"
strict_variables: "%kernel.debug%"
# Doctrine Configuration
doctrine:
dbal:
driver: pdo_mysql
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
# if using pdo_sqlite as your database driver:
# 1. add the path in parameters.yml
# e.g. database_path: "%kernel.root_dir%/data/data.db3"
# 2. Uncomment database_path in parameters.yml.dist
# 3. Uncomment next line:
# path: "%database_path%"
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
# Swiftmailer Configuration
swiftmailer:
transport: "%mailer_transport%"
host: "%mailer_host%"
username: "%mailer_user%"
password: "%mailer_password%"
spool: { type: memory }
I checked for the extension php_pdo_mysql.dl and it is enabled.
I verified the database name, user and password.
here is a netstat :
netstat
Make sure that your MySQL server is running and that it's using that port (in xampp\mysql\bin\my.ini). Make sure that you're able to connect manually with those credentials as well.
Also, where are you specifying the database driver in your parameters.yml? Normally you should have something like this:
database_driver: pdo_mysql
And lastly, make sure that you don't have a different parameters.yml file included in your config_dev.yml because Symfony commands, by default, use the dev environment.
thank you for your answer.
I have in my.ini 3306 port so it is the good one. I have intalled symfony2.8 and it is working so there is no credentials problems. I also tried to add the line with pdo_mysql but the error message is an pdo_exception, that means pdo works as well.
I also check config.dev but I don't really know what can be wrong inside. So I show you what it looks like :
imports:
- { resource: config.yml }
framework:
router:
resource: "%kernel.root_dir%/config/routing_dev.yml"
strict_requirements: true
profiler: { only_exceptions: false }
web_profiler:
toolbar: true
intercept_redirects: false
monolog:
handlers:
main:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
channels: [!event]
console:
type: console
channels: [!event, !doctrine]
# uncomment to get logging in your browser
# you may have to allow bigger header sizes in your Web server configuration
#firephp:
# type: firephp
# level: info
#chromephp:
# type: chromephp
# level: info
#swiftmailer:
# delivery_address: me#example.com
thank for your help
i cant connect to mysql on xamppp
install mysql 8 on my system on port 3307
and its worked great with laravel.
if you want please install mysql workbench (instead of phpmyadmin)
I want to build a site where users can log in register and that stuff. For the User management i use FOSUserbundle. Now i want to use a different db connection for FOSUserBundle than for the other bundles. My config.yml file looks like:
doctrine:
dbal:
default_connection: default
connections:
default:
driver: "%database1_driver%"
host: "%database1_host%"
port: "%database1_port%"
dbname: "§database1_name%"
user: "%database1_user%"
password: "%database1_password%"
charset: UTF8
user:
driver: "%database2_driver%"
host: "%database2_host%"
port: "%database2_port%"
dbname: "%database2_name%"
user: "%database2_user%"
password: "%database2_password%"
charset: UTF8
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
MyProjectMainBundle: ~
user:
connection: user
mappings:
MyProjectUserBundle: ~
When i try to load the page i get the error MappingException: The class 'MyProject\UserBundle\Entity\User' was not found in the chain configured namespaces MyProject\MainBundle\Entity, FOS\UserBundle\Model.
I followed the documentation for FOSUserBundle exactly and it is working if i use
auto_generate_proxy_classes: %kernel.debug%
auto_mapping: true
in config.yml.
The only thing with this is, it only generates the table like defined in the new entity from the documentation. Only an id field is generated, and not the whole fos_user table like it should.
I know some similar questions have been asked before, but I tried using all the solutions from there and it didn't work. So how can I fix this? Is it even possible? I really need to use seperate databases because my project will use a lot of tables and i don't want it to get too messy.
user:
connection: user
mappings:
FOSUserBundle: ~
MyProjectUserBundle: ~
Need to add the FOSUserBundle to your mappings to get rid of the entity error
And make sure you have the model_manager_name set in config.ym;
fos_user:
db_driver: orm
firewall_name: main
user_class: Cerad\Bundle\AccountBundle\Entity\AccountUser
model_manager_name: user